<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Carlos Scheidegger</title>
<link>https://cscheid.net/v2/blog.html</link>
<atom:link href="https://cscheid.net/v2/blog.xml" rel="self" type="application/rss+xml"/>
<description></description>
<generator>quarto-99.9.9</generator>
<lastBuildDate>Thu, 11 Jul 2024 07:00:00 GMT</lastBuildDate>
<item>
  <title>Teaching myself sound synthesis: How not to do oscillators wrong</title>
  <link>https://cscheid.net/v2/blog/2024-07-11.html</link>
  <description><![CDATA[ 




<p>I’m slowly teaching myself sound synthesis by writing Javascript implementations of a number of classic techniques.</p>
<p>I’ve <a href="../explainers/music/karplus-strong.html">written about the Karplus-Strong algorithm for synthesizing plucked strings</a> before.</p>
<p>I’ve started to work my way towards <a href="https://en.wikipedia.org/wiki/Frequency_modulation_synthesis">FM synthesis</a> my usual way: making every possible mistake in the book so you don’t have to. So here’s a basic, fun bug to watch out for: <a href="../explainers/music/oscillators.html">how to not do oscillators incorrectly</a>.</p>


<!-- -->


 ]]></description>
  <category>music</category>
  <guid>https://cscheid.net/v2/blog/2024-07-11.html</guid>
  <pubDate>Thu, 11 Jul 2024 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Install and setup Julia and its Jupyter kernel on macOS</title>
  <link>https://cscheid.net/v2/blog/2023-10-21-b.html</link>
  <description><![CDATA[ 




<p>You need jupyter to be installed and available from your shell</p>
<ul>
<li>Download and install Julia from https://julialang.org.</li>
</ul>
<p>Then:</p>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">$</span> rm <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-rf</span> ~/.julia</span>
<span id="cb1-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">$</span> cd /usr/local/bin</span>
<span id="cb1-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">$</span> ln <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-s</span> /Applications/Julia-<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${VERSION}</span>.app/Contents/Resources/julia/bin/julia .</span>
<span id="cb1-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">$</span> julia</span>
<span id="cb1-5"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> using <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Pkg</span></span>
<span id="cb1-6"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> Pkg.add<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IJulia"</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb1-7"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> using <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">IJulia</span></span>
<span id="cb1-8"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> installkernel<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"julia"</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span></code></pre></div>


<!-- -->


 ]]></description>
  <category>external-memory</category>
  <guid>https://cscheid.net/v2/blog/2023-10-21-b.html</guid>
  <pubDate>Sat, 21 Oct 2023 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Install all library dependencies for a particular renv lockfile</title>
  <link>https://cscheid.net/v2/blog/2023-10-21-c.html</link>
  <description><![CDATA[ 




<p>If you have a big <a href="https://rstudio.github.io/renv/articles/renv.html">renv</a> lockfile and you need to install all dependencies on a new machine, the naive strategy of just doing <code>renv::restore()</code> leads to a loop of:</p>
<ul>
<li><code>renv::restore()</code>,</li>
<li>wait for the next thing that fails to build because of missing system dependency,</li>
<li>install that one system dependency</li>
</ul>
<p>That’s annoying.</p>
<p>Here’s a much better hack that <a href="https://themockup.blog/">Tom Mock</a> taught me about. (Unfortunately, you’ll still hit the above problem if you need dependencies for <code>httr</code>, in particular, <code>libcurl</code> and <code>libssl</code> dev dependencies)</p>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(httr)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(jsonlite)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb1-4"></span>
<span id="cb1-5">lock_json <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> jsonlite<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fromJSON</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"renv.lock"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">simplifyVector =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb1-6"></span>
<span id="cb1-7">pkg_names <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(lock_json<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Packages)</span>
<span id="cb1-8"></span>
<span id="cb1-9">get_install_scripts <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(pkg_names){</span>
<span id="cb1-10"></span>
<span id="cb1-11">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get package info from Posit package manager</span></span>
<span id="cb1-12">    get_pkg_info <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(pkg_name){</span>
<span id="cb1-13"></span>
<span id="cb1-14">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># or whatever your distribution is</span></span>
<span id="cb1-15">        url <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"https://packagemanager.posit.co/__api__/repos/1/sysreqs?all=false&amp;pkgname="</span>, pkg_name, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&amp;distribution=debian"</span>)</span>
<span id="cb1-16">        response <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> httr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">GET</span>(url, httr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">accept_json</span>())</span>
<span id="cb1-17">        raw_json <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> jsonlite<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fromJSON</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">content</span>(response, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">simplifyVector =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb1-18"></span>
<span id="cb1-19">    }</span>
<span id="cb1-20"></span>
<span id="cb1-21">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get install scripts</span></span>
<span id="cb1-22">    all_json <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(pkg_names, get_pkg_info)</span>
<span id="cb1-23"></span>
<span id="cb1-24">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Flatten to a df with install_scripts as a column</span></span>
<span id="cb1-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pkg =</span> pkg_names, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> all_json) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb1-26">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unnest_wider</span>(x) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb1-27">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unnest_longer</span>(requirements) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb1-28">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unnest_wider</span>(requirements) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb1-29">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unnest_wider</span>(requirements) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb1-30">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unnest_longer</span>(install_scripts)</span>
<span id="cb1-31">}</span>
<span id="cb1-32"></span>
<span id="cb1-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_install_scripts</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sf"</span>)</span>
<span id="cb1-34"></span>
<span id="cb1-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># get them all</span></span>
<span id="cb1-36">all_pkgs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_install_scripts</span>(pkg_names)</span>
<span id="cb1-37"></span>
<span id="cb1-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # A tibble: 44 × 4</span></span>
<span id="cb1-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    pkg        name  packages   install_scripts                        </span></span>
<span id="cb1-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;    &lt;chr&gt;      &lt;chr&gt; &lt;list&gt;     &lt;chr&gt;                                  </span></span>
<span id="cb1-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  1 DBI        &lt;NA&gt;  &lt;NULL&gt;     &lt;NA&gt;                                   </span></span>
<span id="cb1-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  2 KernSmooth &lt;NA&gt;  &lt;NULL&gt;     &lt;NA&gt;                                   </span></span>
<span id="cb1-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  3 MASS       &lt;NA&gt;  &lt;NULL&gt;     &lt;NA&gt;                                   </span></span>
<span id="cb1-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  4 R6         &lt;NA&gt;  &lt;NULL&gt;     &lt;NA&gt;                                   </span></span>
<span id="cb1-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  5 Rcpp       &lt;NA&gt;  &lt;NULL&gt;     &lt;NA&gt;                                   </span></span>
<span id="cb1-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  6 arrow      arrow &lt;list [2]&gt; apt-get install -y libcurl4-openssl-dev</span></span>
<span id="cb1-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  7 arrow      arrow &lt;list [2]&gt; apt-get install -y libssl-dev          </span></span>
<span id="cb1-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  8 assertthat &lt;NA&gt;  &lt;NULL&gt;     &lt;NA&gt;                                   </span></span>
<span id="cb1-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  9 bit        &lt;NA&gt;  &lt;NULL&gt;     &lt;NA&gt;                                   </span></span>
<span id="cb1-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; 10 bit64      &lt;NA&gt;  &lt;NULL&gt;     &lt;NA&gt;                                   </span></span>
<span id="cb1-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # ℹ 34 more rows</span></span>
<span id="cb1-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; # ℹ Use `print(n = ...)` to see more rows</span></span>
<span id="cb1-53"></span>
<span id="cb1-54"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## ------- just install steps</span></span>
<span id="cb1-55"></span>
<span id="cb1-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># pull out the install steps</span></span>
<span id="cb1-57">all_installs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> all_pkgs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>install_scripts</span>
<span id="cb1-58"></span>
<span id="cb1-59"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(all_installs))</span>
<span id="cb1-60"></span>
<span id="cb1-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [1] "apt-get install -y libcurl4-openssl-dev"</span></span>
<span id="cb1-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [2] "apt-get install -y libssl-dev"          </span></span>
<span id="cb1-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [3] "apt-get install -y libssl-dev"          </span></span>
<span id="cb1-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [4] "apt-get install -y libssl-dev"          </span></span>
<span id="cb1-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [5] "apt-get install -y libgdal-dev"         </span></span>
<span id="cb1-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [6] "apt-get install -y gdal-bin"            </span></span>
<span id="cb1-67"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [7] "apt-get install -y libgeos-dev"         </span></span>
<span id="cb1-68"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [8] "apt-get install -y libproj-dev"         </span></span>
<span id="cb1-69"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt;  [9] "apt-get install -y libsqlite3-dev"      </span></span>
<span id="cb1-70"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [10] "apt-get install -y libudunits2-dev"     </span></span>
<span id="cb1-71"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#&gt; [11] "apt-get install -y libudunits2-dev"  </span></span></code></pre></div>
<p>For the lockfile in <a href="https://github.com/quarto-dev/quarto-cli">quarto</a>’s test suite and a bare-bones Debian install, this gives 237 dependencies. That’s a lot of saved time!</p>


<!-- -->


 ]]></description>
  <category>external-memory</category>
  <guid>https://cscheid.net/v2/blog/2023-10-21-c.html</guid>
  <pubDate>Sat, 21 Oct 2023 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Create a bootable USB drive from macOS</title>
  <link>https://cscheid.net/v2/blog/2023-10-21.html</link>
  <description><![CDATA[ 




<p>Your USB drive needs to be preformatted with FAT32. Use Disk Utility for this:</p>
<ul>
<li><p>make sure to “Show All Devices” in View.</p></li>
<li><p>click the top-level device for your external drive, on the left window bar, then “erase” on the top window bar.</p>
<p><img src="https://cscheid.net/v2/blog/disk-utility.jpg" class="img-fluid"></p></li>
<li><p>Select “FAT”, “Master Boot Record”</p>
<p><img src="https://cscheid.net/v2/blog/du-erase.jpg" class="img-fluid"></p></li>
</ul>
<p>Then:</p>
<pre><code>$ diskutil list
...
# find the USB drive here.
# IF YOU GET THIS WRONG, YOU WILL CORRUPT SOME OTHER DRIVE. DOUBLE CHECK.
/dev/disk4 (external, physical):
...
$ diskutil unmountDisk /dev/disk4
Unmount of all volumes on disk4 was successful
$ sudo dd if=debian-12.2.0-amd64-netinst.iso of=/dev/rdisk4 bs=1m &amp;&amp; sync</code></pre>
<p>A popup will appear and claim that the disk is not readable. Hit Eject, remove the drive, and use your newly bootable USB drive.</p>
<p>You might also need to configure the computer you’re booting this from to actually boot from a USB device in BIOS settings.</p>


<!-- -->


 ]]></description>
  <category>external-memory</category>
  <guid>https://cscheid.net/v2/blog/2023-10-21.html</guid>
  <pubDate>Sat, 21 Oct 2023 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Pitch sets, keys and modes</title>
  <link>https://cscheid.net/v2/blog/2023-03-12.html</link>
  <description><![CDATA[ 




<p>In one of my recent music lessons, <a href="https://greghoward.bandcamp.com/">my teacher</a> suggested that it would be fun to improvise going between G Lydian and E Ionian (“major”). He instantly suggested these two modes, and clearly in his mind/fingers he knew right away that this is fun because those modes share a bunch of common tones (in this case, they share 5 tones: A, B, D, E, and F♯). That good musicians can do this in a split second is mindblowing to me.</p>
<p>I can’t think so fast (especially not while playing!), so I spent a few hours figuring out how I can make a diagram that makes this stuff obvious. Here’s the result.</p>
<style>
    .dim { opacity: 0.25 }
</style>
<div class="column-page">
<table class="table-small caption-top table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th colspan="15" data-quarto-table-cell-role="th">pitch set</th>
<th data-quarto-table-cell-role="th">modes</th>
<th data-quarto-table-cell-role="th">Ly</th>
<th data-quarto-table-cell-role="th">I</th>
<th data-quarto-table-cell-role="th">M</th>
<th data-quarto-table-cell-role="th">D</th>
<th data-quarto-table-cell-role="th">A</th>
<th data-quarto-table-cell-role="th">P</th>
<th data-quarto-table-cell-role="th">Lo</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>5♭</td>
<td class="dim">C</td>
<td class="dim">D♭</td>
<td class="dim">E♭</td>
<td class="dim">F</td>
<td class="bri">G♭</td>
<td class="dim">A♭</td>
<td class="dim">B♭</td>
<td class="dim">C</td>
<td class="dim">D♭</td>
<td class="dim">E♭</td>
<td class="dim">F</td>
<td class="bri">G♭</td>
<td class="dim">A♭</td>
<td class="dim">B♭</td>
<td class="dim">C</td>
<td class="dim"></td>
<td class="bri">G♭</td>
<td class="dim">D♭</td>
<td class="dim">A♭</td>
<td class="dim">E♭</td>
<td class="dim">B♭</td>
<td class="dim">F</td>
<td class="dim">C</td>
</tr>
<tr class="even">
<td>4♭</td>
<td class="dim">C</td>
<td class="bri">D♭</td>
<td class="dim">E♭</td>
<td class="dim">F</td>
<td class="dim">G</td>
<td class="dim">A♭</td>
<td class="dim">B♭</td>
<td class="dim">C</td>
<td class="bri">D♭</td>
<td class="dim">E♭</td>
<td class="dim">F</td>
<td class="dim">G</td>
<td class="dim">A♭</td>
<td class="dim">B♭</td>
<td class="dim">C</td>
<td class="dim"></td>
<td class="bri">D♭</td>
<td class="dim">A♭</td>
<td class="dim">E♭</td>
<td class="dim">B♭</td>
<td class="dim">F</td>
<td class="dim">C</td>
<td class="dim">G</td>
</tr>
<tr class="odd">
<td>3♭</td>
<td class="dim">C</td>
<td class="dim">D</td>
<td class="dim">E♭</td>
<td class="dim">F</td>
<td class="dim">G</td>
<td class="bri">A♭</td>
<td class="dim">B♭</td>
<td class="dim">C</td>
<td class="dim">D</td>
<td class="dim">E♭</td>
<td class="dim">F</td>
<td class="dim">G</td>
<td class="bri">A♭</td>
<td class="dim">B♭</td>
<td class="dim">C</td>
<td class="dim"></td>
<td class="bri">A♭</td>
<td class="dim">E♭</td>
<td class="dim">B♭</td>
<td class="dim">F</td>
<td class="dim">C</td>
<td class="dim">G</td>
<td class="dim">D</td>
</tr>
<tr class="even">
<td>2♭</td>
<td class="dim">C</td>
<td class="dim">D</td>
<td class="bri">E♭</td>
<td class="dim">F</td>
<td class="dim">G</td>
<td class="dim">A</td>
<td class="dim">B♭</td>
<td class="dim">C</td>
<td class="dim">D</td>
<td class="bri">E♭</td>
<td class="dim">F</td>
<td class="dim">G</td>
<td class="dim">A</td>
<td class="dim">B♭</td>
<td class="dim">C</td>
<td class="dim"></td>
<td class="bri">E♭</td>
<td class="dim">B♭</td>
<td class="dim">F</td>
<td class="dim">C</td>
<td class="dim">G</td>
<td class="dim">D</td>
<td class="dim">A</td>
</tr>
<tr class="odd">
<td>1♭</td>
<td class="dim">C</td>
<td class="dim">D</td>
<td class="dim">E</td>
<td class="dim">F</td>
<td class="dim">G</td>
<td class="dim">A</td>
<td class="bri">B♭</td>
<td class="dim">C</td>
<td class="dim">D</td>
<td class="dim">E♭</td>
<td class="dim">F</td>
<td class="dim">G</td>
<td class="dim">A</td>
<td class="dim">B♭</td>
<td class="dim">C</td>
<td class="dim"></td>
<td class="bri">B♭</td>
<td class="dim">F</td>
<td class="dim">C</td>
<td class="dim">G</td>
<td class="dim">D</td>
<td class="dim">A</td>
<td class="dim">E</td>
</tr>
<tr class="even">
<td>0♭</td>
<td class="bri">C</td>
<td class="bri">D</td>
<td class="bri">E</td>
<td class="bri">F</td>
<td class="bri">G</td>
<td class="bri">A</td>
<td class="bri">B</td>
<td class="bri">C</td>
<td class="bri">D</td>
<td class="bri">E</td>
<td class="bri">F</td>
<td class="bri">G</td>
<td class="bri">A</td>
<td class="bri">B</td>
<td class="bri">C</td>
<td class="dim"></td>
<td class="bri">F</td>
<td class="bri">C</td>
<td class="bri">G</td>
<td class="bri">D</td>
<td class="bri">A</td>
<td class="bri">E</td>
<td class="bri">B</td>
</tr>
<tr class="odd">
<td>1♯</td>
<td class="dim">C</td>
<td class="dim">D</td>
<td class="dim">E</td>
<td class="bri">F♯</td>
<td class="dim">G</td>
<td class="dim">A</td>
<td class="dim">B</td>
<td class="dim">C</td>
<td class="dim">D</td>
<td class="dim">E</td>
<td class="bri">F♯</td>
<td class="dim">G</td>
<td class="dim">A</td>
<td class="dim">B</td>
<td class="dim">C</td>
<td class="dim"></td>
<td class="dim">C</td>
<td class="dim">G</td>
<td class="dim">D</td>
<td class="dim">A</td>
<td class="dim">E</td>
<td class="dim">B</td>
<td class="bri">F♯</td>
</tr>
<tr class="even">
<td>2♯</td>
<td class="bri">C♯</td>
<td class="dim">D</td>
<td class="dim">E</td>
<td class="dim">F♯</td>
<td class="dim">G</td>
<td class="dim">A</td>
<td class="dim">B</td>
<td class="bri">C♯</td>
<td class="dim">D</td>
<td class="dim">E</td>
<td class="dim">F♯</td>
<td class="dim">G</td>
<td class="dim">A</td>
<td class="dim">B</td>
<td class="bri">C♯</td>
<td class="dim"></td>
<td class="dim">G</td>
<td class="dim">D</td>
<td class="dim">A</td>
<td class="dim">E</td>
<td class="dim">B</td>
<td class="dim">F♯</td>
<td class="bri">C♯</td>
</tr>
<tr class="odd">
<td>3♯</td>
<td class="dim">C♯</td>
<td class="dim">D</td>
<td class="dim">E</td>
<td class="dim">F♯</td>
<td class="bri">G♯</td>
<td class="dim">A</td>
<td class="dim">B</td>
<td class="dim">C♯</td>
<td class="dim">D</td>
<td class="dim">E</td>
<td class="dim">F♯</td>
<td class="bri">G♯</td>
<td class="dim">A</td>
<td class="dim">B</td>
<td class="dim">C♯</td>
<td class="dim"></td>
<td class="dim">D</td>
<td class="dim">A</td>
<td class="dim">E</td>
<td class="dim">B</td>
<td class="dim">F♯</td>
<td class="dim">C♯</td>
<td class="bri">G♯</td>
</tr>
<tr class="even">
<td>4♯</td>
<td class="dim">C♯</td>
<td class="bri">D♯</td>
<td class="dim">E</td>
<td class="dim">F♯</td>
<td class="dim">G♯</td>
<td class="dim">A</td>
<td class="dim">B</td>
<td class="dim">C♯</td>
<td class="bri">D♯</td>
<td class="dim">E</td>
<td class="dim">F♯</td>
<td class="dim">G♯</td>
<td class="dim">A</td>
<td class="dim">B</td>
<td class="dim">C♯</td>
<td class="dim"></td>
<td class="dim">A</td>
<td class="dim">E</td>
<td class="dim">B</td>
<td class="dim">F♯</td>
<td class="dim">C♯</td>
<td class="dim">G♯</td>
<td class="bri">D♯</td>
</tr>
<tr class="odd">
<td>5♯</td>
<td class="dim">C♯</td>
<td class="dim">D♯</td>
<td class="dim">E</td>
<td class="dim">F♯</td>
<td class="dim">G♯</td>
<td class="dim">A♯</td>
<td class="dim">B</td>
<td class="dim">C♯</td>
<td class="dim">D♯</td>
<td class="dim">E</td>
<td class="dim">F♯</td>
<td class="dim">G♯</td>
<td class="bri">A♯</td>
<td class="dim">B</td>
<td class="dim">C♯</td>
<td class="dim"></td>
<td class="dim">E</td>
<td class="dim">B</td>
<td class="dim">F♯</td>
<td class="dim">C♯</td>
<td class="dim">G♯</td>
<td class="dim">D♯</td>
<td class="bri">A♯</td>
</tr>
</tbody>
</table>
</div>
<p>The legend for the modes columns:</p>
<ul>
<li><strong>Ly</strong>: Lydian</li>
<li><strong>I</strong>: Ionian</li>
<li><strong>M</strong>: Mixolydian</li>
<li><strong>D</strong>: Dorian</li>
<li><strong>A</strong>: Aeolian</li>
<li><strong>P</strong>: Phrygian</li>
<li><strong>Lo</strong>: Locrian</li>
</ul>
<section id="how-to-use-this-for-the-original-problem" class="level2">
<h2 class="anchored" data-anchor-id="how-to-use-this-for-the-original-problem">How to use this for the original problem</h2>
<p>The rows on this scale are “pitch sets”, sets of specific pitches which differ by exactly one pitch class. You can think of it as the “key signature” on a piece of sheet music, which happens to not always denote keys especially if the song is in a less-traditional-in-18th-century-Europe mode like Phrygian.</p>
<section id="the-original-example" class="level3">
<h3 class="anchored" data-anchor-id="the-original-example">The original example</h3>
<p>If we want to compare G Lydian to E Ionian, like my teacher suggested, we look up the rows where each mode-tonic pair are. G Lydian has a pitch class (aka a set of notes) with two sharps, and E Ionian has a scale with four. So it’s a lot clearer (to me at least) that the two different notes have to be G and D (natural in G Lydian, sharp in E Ionian)</p>
<p>But the diagram now makes it easier (again, for me at least) to do this in my head. Once you start thinking of modes as sharper or flatter (as implied by the ordering in the modes columns), as well as thinking of the “distance in the circle of fifths” between pitch classes, then you can do this in your head. Example:</p>
<p>G is “three fifth-steps flatter” than E: circle of fifths says “G, D, A, E”. Lydian is “one mode” sharper than Ionian (see the ordering above). So to change between G Lydian and E Ionian, we’ll have to go “up two sharps”, and those are the ones in the last column of the modes column as we go from the row of G Lydian to the one of E Ionian (because as we go sharper, we remove the note from the first mode column and add the one in the last column; the note changes go the other way if we go flatter).</p>
</section>
<section id="other-examples" class="level3">
<h3 class="anchored" data-anchor-id="other-examples">Other examples</h3>
<ul>
<li>(Same tonic notes, different modes) G Mixolydian to E Locrian. From 0 flats to 1 flat, so that must be B to B♭</li>
<li>A Dorian to F Ionian. From 1 sharp to 1 flat, so that must be F♯ to F, B to B♭.</li>
</ul>
<p>A general rule about this exercise, then, is that the notes which change are always a consecutive row of notes in the circle of fifths. (This is the same observation that allows you to very easily know which notes are flat or sharp by just counting accidentals off of a key signature.)</p>
</section>
</section>
<section id="other-uses" class="level2">
<h2 class="anchored" data-anchor-id="other-uses">Other uses</h2>
<p>This organization tells you when you “weird stuff will start happening”: it’s when you move away from the “middle” of this table. You can imagine this table extending infinitely up or down.</p>
<p>If you stay within two rows of the center, then nothing weird happens. All notes with different names sound different, and everything is fine. But then you don’t have a name for A♭/G♯.</p>
<p>If you decide to add the next rows, you either end up with an asymmetrical table, or you end up with two notes that have different names and sound the same. In other words, the (in)famous “enharmonic equivalence” shows up.</p>
<p>The next two rows up and down are necessary to be able to describe the notes of modes of the white keys, and add new enharmonic equivalents. For example, C Locrian needs a G♭, (that’s <em>not</em> an F♯!, because F is already there as a natural in the mode!).</p>
<p>Finally, if you were to add any more notes up or down, you’d start having white keys being enharmonic equivalent to other white keys. Going up the table you will see C♭ and F♭, and going down the table will produce E♯ and B♯.</p>
<p>But that’s not all! One more step up or down the table, and you’ll see the dreaded double sharps (𝄪) and double flats. That’s how they come up “in practice”. If you’re doing weird modes and key changes, you might find yourself in (say) G♯ Ionian, where in order for the note names to make sense, you can’t avoid C𝄪 and F𝄪!</p>


<!-- -->

</section>

 ]]></description>
  <category>music</category>
  <guid>https://cscheid.net/v2/blog/2023-03-12.html</guid>
  <pubDate>Sun, 12 Mar 2023 07:00:00 GMT</pubDate>
</item>
<item>
  <title>TypeScript 4.9: NaN sanity, finally!</title>
  <link>https://cscheid.net/v2/blog/2022-12-16.html</link>
  <description><![CDATA[ 




<p><a href="https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#checks-for-equality-on-nan">TypeScript 4.9 is out</a>, and it doesn’t let you use <code>===</code> and <code>!==</code> on <code>NaN</code> by default. Finally someone decided to do this, it’s a legitimately smart move.</p>
<p>This is also a “JavaScript variant” having better equality behavior than <em>Haskell</em> (nevermind my ancient GHC version, thankyouverymuch):</p>
<pre><code>$ ghci
GHCi, version 8.10.7: https://www.haskell.org/ghc/  :? for help
Prelude&gt; let x = 0.0 / 0.0
Prelude&gt; x == x
False</code></pre>
<p>Signed zeros, denormals, and infinities all make some sense in context of numerical analysis. But reflexivity is too strong a property to give up, and it’s pretty gross that vaunted Haskell does this with its values and <code>==</code> function.</p>
<p>Right from the start, these weird comparison operators that have no simple algebraic properties should have been <code>floatLess</code> instead of <code>&lt;</code>, <code>floatEquals</code> instead of <code>==</code>, etc. But we’re stuck with a horrible standard, and at least TypeScript can do minimally better.</p>


<!-- -->


 ]]></description>
  <category>programming</category>
  <guid>https://cscheid.net/v2/blog/2022-12-16.html</guid>
  <pubDate>Fri, 16 Dec 2022 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Copiloting my way through Advent of Code</title>
  <link>https://cscheid.net/v2/blog/2022-12-04.html</link>
  <description><![CDATA[ 




<p>Because of my work on <a href="https://quarto.org">quarto</a>, Microsoft offers me free access to GitHub Copilot (this is true for contributors of sufficiently popular open source repositories on GitHub). It’s a smart move by Microsoft: they’ve gone ahead and crawled all of GitHub without caring too much about licensing issues, so presumably now they’re preemptively extending olive branches to open source software developers.</p>
<p>Since 2022’s advent of code is going on right now, I figured I’d try it out in a <a href="https://deno.land">bog-standard programming language</a>, so I could see how much it actually knows. I’m very impressed, and I’m usually quite cynical about this kind of stuff. (Copilot is also enabled by default in Markdown. So as I type this, it is happily suggesting things. As you’ll see, it’s… hit and miss.)</p>
<section id="copilot-memorizes-solutions" class="level3">
<h3 class="anchored" data-anchor-id="copilot-memorizes-solutions">Copilot memorizes solutions</h3>
<p>Try solving the 2015 AOC problems. If you give your program file a name that indicates the year and number of the problem, Copilot will suggest variable names that show very clearly that it knows the solution. It’s remarkable to see. It knows that the indexing required in some problems is 0-based, and in others is 1-based.</p>
</section>
<section id="its-very-good-at-teaching-you-apis-and-tricks" class="level3">
<h3 class="anchored" data-anchor-id="its-very-good-at-teaching-you-apis-and-tricks">It’s very good at teaching you APIs and tricks</h3>
<p>Just today, Copilot taught me that you can swap two variables in javascript using destructuring assignments, even without declarations. I knew that</p>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode javascript code-with-copy"><code class="sourceCode javascript"><span id="cb1-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> [a<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> b] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d]</span></code></pre></div>
<p>was possible, but I didn’t know that</p>
<div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode javascript code-with-copy"><code class="sourceCode javascript"><span id="cb2-1">[a<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> b] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [b<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> a]</span></code></pre></div>
<p>also worked. That’s a trivial, minor thing, but it’s a good trick to have under your fingers. The most surprising thing about Copilot is that it’s <em>teaching</em> me. If you’re comfortable with ignoring some clearly bad suggestions, you’re likely to learn a new thing every few days.</p>
</section>
<section id="its-pretty-good-at-simple-functions" class="level3">
<h3 class="anchored" data-anchor-id="its-pretty-good-at-simple-functions">It’s pretty good at simple functions</h3>
<p>Give it a few examples and it will suggest a function that works. It’s great for when you know a function is easy to write, but you don’t want to rederive it:</p>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode javascript code-with-copy"><code class="sourceCode javascript"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// d(0) = 0</span></span>
<span id="cb3-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// d(1) = 1</span></span>
<span id="cb3-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// d(2) = 3</span></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// d(3) = 6</span></span>
<span id="cb3-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// d(4) = 10</span></span>
<span id="cb3-6"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> number) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// Copilot knew this</span></span></code></pre></div>
</section>
<section id="it-cant-really-write-prose" class="level3">
<h3 class="anchored" data-anchor-id="it-cant-really-write-prose">It can’t really write prose</h3>
<p>Copilot itself is <a href="https://mastodon.social/@scheidegger/109458554184293542">hilariously bad at text</a>. But what’s remarkable to me is that Copilot is much better at coding than the very latest chatbots are at natural language.</p>
</section>
<section id="its-very-good-at-boilerplate" class="level3">
<h3 class="anchored" data-anchor-id="its-very-good-at-boilerplate">It’s very good at boilerplate</h3>
<p>Copilot truly shines at boilerplate code. If you structure your code so that it’s amenable to a simple case analysis, it’s very likely that that it can complete a <code>switch</code> statement from the first couple of cases. It also knows its way around the code in your workspace, so if your other files offer hints about your data structures or APIs, that tends to help.</p>
<p>It’s so good at following explicit structured boilerplate that I wonder if Copilot would be especially good with a language like SML. For example, Copilot consistently fails at distinguishing the different ways of determining data structure sizes in Lua (e.g.&nbsp;<code>#t</code> vs <code>table.getn(t)</code> vs <code>t.n</code>). I suspect this is because there is very little syntactic distinction between the different situations. But in a well-designed language like SML, this would not only be a non-issue, but the uniformity of the treatment would make it easier for Copilot to learn. And SML can be a little verbose, Copilot would presumably help with that.</p>
<p>On a more somber note, I wonder if Haskell+Copilot programmers would ever feel the need to invent lenses or arrows or traversables or universal folds. Here’s a bit of heresy: non-DRY code is not so bad when the repetition is local and Copilot knows about it.</p>
<p>Where the next Copilot-like jump in suggestions will need to come from is <em>non-local</em> suggestions, finding places to edit your code that are not under the cursor. That kind of boilerplate is still totally on the programmer, if for no other reason than the Copilot UX is very cursor-centric.</p>
</section>
<section id="why-is-it-so-good-at-coding" class="level2">
<h2 class="anchored" data-anchor-id="why-is-it-so-good-at-coding">Why is it so good at coding?</h2>
<p>Copilot here suggested me that</p>
<blockquote class="blockquote">
<p>it’s because the code is much more structured than natural language</p>
</blockquote>
<p>I don’t think that’s it. I think the reason is that there’s a much stronger constraint on what source code ends up on GitHub than there is unstructured text on the internet. Code on GitHub is presumably interesting and good enough to warrant being on a repository. Text on the internet on the other hand, is maybe more like this blog.</p>
<section id="copilot-and-lsp-are-great-friends" class="level3">
<h3 class="anchored" data-anchor-id="copilot-and-lsp-are-great-friends">Copilot and LSP are great friends</h3>
<p>Like I said, I’m using Copilot with Deno. What’s very cool is that although the two pieces of technology offer “suggestions:, they tend to be orthogonal and they help one another. Again, because source code has semantic constraints, it’s also easier to tell when Copilot makes a nonsense suggestion, and Deno’s LSP does a great job at that.</p>
<p>You could even envision a future Copilot implementation having access to the LSP and only attempting semantically-valid suggestions.</p>
</section>
</section>
<section id="are-us-excel-farmers-going-to-be-out-of-a-job" class="level2">
<h2 class="anchored" data-anchor-id="are-us-excel-farmers-going-to-be-out-of-a-job">Are us excel farmers going to be out of a job?</h2>
<p>One of my favorite descriptions of the modern knowledge worker is a “spreadsheet farmer”. This is not to throw shade at farmers of either kind (and have you tried anything like growing food? It’s <em>hard work</em>). But the idea is that there’s a large group of people who end up doing essential work which happens to be of a relatively repetitive nature.</p>
<p>A few years ago, I expect that if you were to ask people about which jobs would go away the soonest, you’d get “drivers, because self-driving cars”. I now think that a better answer is “spreadsheet farmers, because Copilot”.</p>
<p>But there’s at least two ways to think of what AI is going to do to programmers. It’s clearly the case that it’s a force multiplier. But is it a force multiplier like farming implements were force multipliers, where the workforce went from ~50% to under 2% <a href="https://ourworldindata.org/employment-in-agriculture">in 150 years</a>?</p>
<iframe src="https://ourworldindata.org/grapher/share-of-the-labor-force-employed-in-agriculture?tab=chart&amp;time=1800..latest&amp;country=ITA~FRA~NLD~POL~GBR" loading="lazy" style="width: 100%; height: 600px; border: 0px none;">
</iframe>
<p>If you look at employment statistics, farming, transportation, and manufacturing have <a href="https://www.bls.gov/opub/ted/2016/employment-by-industry-1910-and-2015.htm">pretty much all been replaced by service work</a>. Are we going to get a new type of work that will exist once service work is automatable like farming was? Or are we changing the nature of service work such that there’ll be even more demand for it? Are those the same thing?</p>


<!-- -->

</section>

 ]]></description>
  <category>programming</category>
  <guid>https://cscheid.net/v2/blog/2022-12-04.html</guid>
  <pubDate>Sun, 04 Dec 2022 07:00:00 GMT</pubDate>
</item>
<item>
  <title>The Chapman Stick</title>
  <link>https://cscheid.net/v2/blog/2022-11-27.html</link>
  <description><![CDATA[ 




<p>I told myself as I was going through the tenure-track grind that I’d buy myself a Chapman Stick as a tenure gift to myself. My tenure notification arrived sometime in February 2020.</p>
<p>A few weeks after, I went to the <a href="https://www.stick.com">Stick enterprises site</a> and placed an order for a sweet Railboard. A couple of days went by, and I get a call from them. Do you remember what was going on in March 2020? … yeah. Turns out the pickup manufacturer was shut down and they didn’t know how long it’d be until they’d them again. As far as I can tell, the answer was, basically, “never”, they actually had to come up with new pickups for the railboard. So it was not until early 2021 that I finally got it.</p>
<p>I’ve finally started taking lessons earlier this year. It’s a lot of fun to play. The best way I know how to describe it is that it’s somewhere in the middle of a guitar, piano, bass, and cello. Here’s the first piece I managed to learn well enough to record a video on it:</p>
<div class="quarto-video"><iframe data-external="1" src="https://www.youtube.com/embed/IsYzu0_pFuY" width="100%" height="400" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
<p>As I learn more, I’ll post more.</p>
<section id="stick-nerdery-ahed" class="level2">
<h2 class="anchored" data-anchor-id="stick-nerdery-ahed">Stick nerdery ahed</h2>
<p>But, you might ask, why the Stick?</p>
<section id="have-you-ever-tried-to-bend-a-note-on-a-piano" class="level3">
<h3 class="anchored" data-anchor-id="have-you-ever-tried-to-bend-a-note-on-a-piano">Have you ever tried to bend a note on a piano?</h3>
<p>I’ve instinctively tried to “bend” a note on a piano by “shaking” the key. It’s annoying and embarrassing! :) I always wanted something that gave me the expressivity of a guitar, but with the range of a piano or smaller synth. The Stick does something very much like that!</p>
<p>When I was looking around, I found out there’s also the <a href="https://en.wikipedia.org/wiki/Harpejji">harpejji</a>. It looks super cool too, and it also has its own uniquely cool tuning, though it’s closer to the <a href="Chromatic_button_accordion">chromatic button accordion system</a>. But. The Stick is already not a cheap instrument, and a Harpejji with comparable range is easily two or three times as expensive. And there’s one thing about the Harpejji that I think they need to solve first. Because it has so many strings and pickups, it’s pretty clearly the case that there’s some cross talk on the pickups. So they figured out a clever electronic way to solve the problem by only turning on the pickups when the string is actively touching the fret. But I think that somehow this gives the harpejji notes a pretty distinct attack, and I’m not 100% sure I love it.</p>
<p>I’m sure this will be improved in time, and I’m looking forward to eventually spending a decade learning the harpejji, but this decade at least is going to the Stick :)</p>
</section>
<section id="tuning" class="level3">
<h3 class="anchored" data-anchor-id="tuning">Tuning</h3>
<p>The standard configurations of the Stick have a bass side and a melody side. I have a 10-string railboard (a “railboard” is their name for an all-metal stick), which has 5 melody strings and 5 bass strings.</p>
<p>The melody side of a Stick is tuned almost like a guitar. In a guitar tuning, the trick of tuning the second interval of a guitar as a major third instead of a perfect fourth gives you a lot of open-string chords (the “cowboy chords” in a guitar). But because you almost always tap a specific fret, you never really play open strings on a Stick. So the Stick melody side is tuned in straight fourths. This makes it so that chord shapes are uniform across the neck.</p>
<p>The bass side of a Stick, on the other hand, is tuned a little like a cello, in perfect fifths. The fifths tuning does make the super low notes stand out from each other a bit better than a standard bass tuning (there’s a <a href="../explainers/music/consonance-and-dissonance.html">psychoachoustic reason for that</a>: lower-pitched sounds sound more like each other compared to higher-pitched sounds).</p>
<p>Unlike a cello, however, the bass strings are laid out in reverse order, so that the lowest string is on the center of the fretboard, and the highest bass side string is opposite the highest melody string. For people who are used to other string instruments, this is apparently very weird and hard to make sense of. But I’ve never really studied guitar seriously at all, so I don’t have any real background to unlearn.</p>
<p>This reversed layout, though, is what really gives the Stick its unique character: It makes the chord shapes work uniformly across the bass and guitar sides (!). If you go up one perfect fourth (same fret, one string down) from C on the melody side, you end up on F. But if you down one perfect fifth (same fret, one string down) from C on the bass side, you <em>also</em> end up on F, just one octave down. So the same shape produces the same chords on the bass and melody sides, but on different voicings. For example, the shape that gives you a chord in first inversion on the melody side gives you a root-fifth-tenth version of the chord. As you learn voicings on one side, they just translate readily to the other side.</p>
<p>This strange sideways layout gives you bass strings in fifths (which sound great like a cello), melody strings in fourths (which are almost like a guitar, so pretty familiar), and the same chord shapes on both sides. It’s a really cool tuning.</p>
<p>You get a few cool side effects of this regular tuning too. For example, the fretboard markers on a stick are regularly spaced at 5 semitones (a perfect fourth), so they are a better map of what’s going on on the instrument: move up or down along a “marker space-full”, and that’s the same as moving up or down a string on the melody side. It doesn’t quite match the bass side, but you learn the notes on the melody and the bass just works out in the other direction.</p>
<p>It’s all very neat.</p>
</section>
<section id="and-its-weird" class="level3">
<h3 class="anchored" data-anchor-id="and-its-weird">And it’s weird!</h3>
<p>I like weird!</p>
<p>And finally, hear <a href="https://www.youtube.com/watch?v=dYKB6Lag-wg">this</a> and <a href="https://www.youtube.com/watch?v=T1CX1x6oulY">this</a>. How can you not love the thing?</p>


<!-- -->

</section>
</section>

 ]]></description>
  <category>hobbies</category>
  <category>music</category>
  <guid>https://cscheid.net/v2/blog/2022-11-27.html</guid>
  <pubDate>Sun, 27 Nov 2022 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Same site, new look</title>
  <link>https://cscheid.net/v2/blog/2022-11-20.html</link>
  <description><![CDATA[ 




<p>It’s been a while! The birdsite ate blogging, and then the muskrat ate the birdsite. As insurance policy, I’m on <a href="https://mastodon.social/@scheidegger">mastodon</a>. But I’m trying blogging again.</p>
<p>Also, I changed jobs. (I managed a good 6 months without writing the requisite academic quit-lit piece, but I make no future promises!) I’m now an engineer at <a href="https://posit.co">Posit</a>. We used to be called RStudio, and you might remember that name instead! We still build RStudio, and still build world-class open-source R libraries. But we’ve been making tools for other ecosystems for a long while, and the R-centric name got in the way a little bit.</p>
<p>I work full-time on <a href="https://quarto.org">quarto</a>, which I’m really excited about. I think we might actually make a dent on technical and academic communication. More about it soon.</p>
<p>I’m not planning on turning comments back on. If you want to say hi, send me an email (start with the email address you see on the main page, but use Posit’s domain instead) or a note on Mastodon. Maybe we’ll do manual trackback links here like it’s 2001 or something!</p>


<!-- -->


 ]]></description>
  <guid>https://cscheid.net/v2/blog/2022-11-20.html</guid>
  <pubDate>Sun, 20 Nov 2022 07:00:00 GMT</pubDate>
</item>
<item>
  <title>A JS Cadence Sensor</title>
  <link>https://cscheid.net/v2/hacks/cadence-sensor.html</link>
  <description><![CDATA[ 




<p>At some point during the pandemic, I became suspicious about the accuracy of my <a href="https://saris.com/products/h3-direct-drive-smart-trainer">Saris H3</a> cadence sensor, so I wrote my own. (It turns out that the cadence sensor is fine.)</p>
<script src="../src/lib/d3.v5.js"></script>
<script src="../src/lib/dsp.js"></script>
<button id="start">
Start Cadence Sensor
</button>
<div>
RPM: <span id="rpm-reader"></span>
</div>
<div id="error-message">

</div>
<div id="chart1">

</div>
<div id="chart2">

</div>
<script src="cadence-sensor/main.js"></script>
<section id="how-it-works" class="level2">
<h2 class="anchored" data-anchor-id="how-it-works">How it works</h2>
<p>The algorithm is embarrassingly simple for how well it works:</p>
<ul>
<li>Capture the time series of the accelerometer data (with a 1s half-life exponential decay),</li>
<li>compute the PCA, and extract the first principal component. You now have a 1D time series</li>
<li>Compute the FFT, and find the period with largest energy.</li>
</ul>
<p>Smartphones: supercomputer processing power, tricorder sensors. Amazing stuff.</p>


<!-- -->

</section>

 ]]></description>
  <category>signal-processing</category>
  <guid>https://cscheid.net/v2/hacks/cadence-sensor.html</guid>
  <pubDate>Thu, 02 Jun 2022 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Bunimovich Stadium</title>
  <link>https://cscheid.net/v2/hacks/bunimovich-stadium.html</link>
  <description><![CDATA[ 




<script src="../src/lib/d3.v5.js"></script>
<p>The Bunimovich Stadium is one example of a <a href="https://en.wikipedia.org/wiki/Dynamical_billiards">Dynamical Billiards</a> table that exhibits chaotic behavior even with only concave scatterings. Trajectories in the Bunimovich stadium exhibit (eventual) exponential divergence over time.</p>
<p>In addition, <a href="https://en.wikipedia.org/wiki/Almost_surely">almost any</a> trajectory in a Bunimovich stadium eventually gets arbitrarily close to any point of the stadium. This is in sharp contrast to trajectories in elliptical billiards: any one trajectory in elliptical billiards will always leave a chunk of the table unexplored.</p>
<div id="main">

</div>
<div id="reset-bunimovich">

</div>
<div id="reset-elliptical">

</div>
<div id="clear-tracks">

</div>
<script type="module" src="bunimovich-stadium/main.js"></script>
<section id="acknowledgments" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgments">Acknowledgments</h2>
<p>Inspiration for this post came from <a href="http://blogs.ams.org/visualinsight/2016/11/15/bunimovich-stadium/">Baez’s post on the stadium</a>.</p>


<!-- -->

</section>

 ]]></description>
  <category>mathematics</category>
  <guid>https://cscheid.net/v2/hacks/bunimovich-stadium.html</guid>
  <pubDate>Sat, 14 Nov 2020 07:00:00 GMT</pubDate>
  <media:content url="https://cscheid.net/v2/images/bunimovich-stadium.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>An Interactive Fagan Nomogram</title>
  <link>https://cscheid.net/v2/hacks/fagan-nomogram.html</link>
  <description><![CDATA[ 




<!-- <script src="/src/lib/d3.v5.js"></script>
 -->
<p>The Fagan nomogram <span class="citation" data-cites="letter1975nomogram">(Fagan 1975)</span> is a nomogram <span class="citation" data-cites="enwiki:1085193589">(Wikipedia contributors 2022)</span> that computes the probability of the presence of some condition based on an imperfect test and varying pre-test probabilities. It is a very handy tool to understand Bayes’s Theorem “physically”. People typically have a sense that the less powerful the test, the less likely it is that a positive test result means the presence of the condition. But people are much less likely to grasp the role of the pre-test probability <span class="citation" data-cites="casscells1978interpretation">(Casscells, Schoenberger, and Graboys 1978)</span>.</p>
<p>As an illustration, consider the example illustrated in the default setting of the nomogram below. If only 10% of the population exhibit a particular kind of condition, then even if a test gives a ratio of true positives to false positives at 10 to 1, only 50% of the people tested positive will actually exhibit the condition.</p>
<p>Similarly, if only 10% of the population exhibits the condition, then in order to be 90% sure that a positive result indicates the presence of the condition, the test can give a false-positive result only 1 every 100 times it gives true positive results. Intuitively, what’s going on is that the base-10 logarithm of the “likelihood ratio” (10 and 100 respectively in the examples above) is the “number of nines added to the baseline probability”, interpreting a probability of 0.1 as having “negative 1 nine”.</p>
<p>The original nomogram was meant to be used with a physical ruler to do the calculations. Here, you can grab the circles and move them around to change the settings.</p>
<div id="main">

</div>
<!-- <script type="module" src="fagan-nomogram/main.js"></script> -->
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1" data-startfrom="46" data-source-offset="-0" style="background: #f1f3f5;"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 45;"><span id="cb1-46"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> { svg } <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/src/cscheid/cscheid.js"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-47"></span>
<span id="cb1-48">{</span>
<span id="cb1-49">  svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setupD3Prototype</span>(d3)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-50"></span>
<span id="cb1-51">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> svgNode <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#main"</span>)</span>
<span id="cb1-52">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"svg"</span>)</span>
<span id="cb1-53">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"viewBox"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0 0 920 400"</span>)</span>
<span id="cb1-54">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"100%"</span>)</span>
<span id="cb1-55">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"100%"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-56"></span>
<span id="cb1-57">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> scaleBounds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">700</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-58"></span>
<span id="cb1-59">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> preTestScaleLogOdds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()</span>
<span id="cb1-60">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>])</span>
<span id="cb1-61">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(scaleBounds)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-62"></span>
<span id="cb1-63">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> postTestScaleLogOdds <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()</span>
<span id="cb1-64">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>])</span>
<span id="cb1-65">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(scaleBounds)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-66"></span>
<span id="cb1-67">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> logLikelihoodRatioScale <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()</span>
<span id="cb1-68">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>])</span>
<span id="cb1-69">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(scaleBounds)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-70"></span>
<span id="cb1-71">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> labels <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pre-test probability'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-72">                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'likelihood ratio'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-73">                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'post-test probability'</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-74"></span>
<span id="cb1-75">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> yScale <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-76"></span>
<span id="cb1-77">  svgNode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-78">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>)</span>
<span id="cb1-79">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(labels)</span>
<span id="cb1-80">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()</span>
<span id="cb1-81">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>)</span>
<span id="cb1-82">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">910</span>)</span>
<span id="cb1-83">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i) { <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">yScale</span>(i)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> })</span>
<span id="cb1-84">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dy"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb1-85">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">text</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d) { <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> })</span>
<span id="cb1-86">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"class"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"label"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-87"></span>
<span id="cb1-88">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> preTestLineG <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svgNode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-89">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> preTestLine <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> preTestLineG</span>
<span id="cb1-90">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>)</span>
<span id="cb1-91">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">preTestScaleLogOdds</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb1-92">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">preTestScaleLogOdds</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb1-93">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb1-94">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb1-95">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"class"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"test-line"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-96"></span>
<span id="cb1-97">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> lrLineG <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svgNode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-98">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> lrLine <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> lrLineG</span>
<span id="cb1-99">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>)</span>
<span id="cb1-100">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">logLikelihoodRatioScale</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>))</span>
<span id="cb1-101">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">logLikelihoodRatioScale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>))</span>
<span id="cb1-102">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>)</span>
<span id="cb1-103">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>)</span>
<span id="cb1-104">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"class"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"test-line"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-105"></span>
<span id="cb1-106">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> postTestLineG <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svgNode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-107">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> postTestLine <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> postTestLineG</span>
<span id="cb1-108">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>)</span>
<span id="cb1-109">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">postTestScaleLogOdds</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb1-110">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">postTestScaleLogOdds</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb1-111">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb1-112">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb1-113">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"class"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"test-line"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-114"></span>
<span id="cb1-115">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//////////////////////////////////////////////////////////////////////////////</span></span>
<span id="cb1-116">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// this could be solved automatically..</span></span>
<span id="cb1-117"></span>
<span id="cb1-118">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expFmt</span>(v) {</span>
<span id="cb1-119">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> l <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pow</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> v)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-120">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fmt</span>(l <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> l))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-121">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> r</span>
<span id="cb1-122">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">/0</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+$</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb1-123">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(\.</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">09</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+$</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> (match<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> p1) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>p1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">1`</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// i'm so sorry, universe.</span></span>
<span id="cb1-124">  }</span>
<span id="cb1-125"></span>
<span id="cb1-126">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lrFmt</span>(v) {</span>
<span id="cb1-127">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> l <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pow</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> v)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-128">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (l <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~~</span>l)</span>
<span id="cb1-129">          <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">String</span>(l)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-130">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> </span>
<span id="cb1-131">          <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">String</span>(l)</span>
<span id="cb1-132">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">/0</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+$</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb1-133">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(\.</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">09</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+$</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> (match<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> p1) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>p1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">1`</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// i'm so sorry, universe.</span></span>
<span id="cb1-134">  }</span>
<span id="cb1-135"></span>
<span id="cb1-136">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> preProbTicks <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {</span>
<span id="cb1-137">      <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">list</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> [<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.954245</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.954245</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-138">      <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">scale</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> preTestScaleLogOdds<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-139">      <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">fmt</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> expFmt</span>
<span id="cb1-140">  }<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-141"></span>
<span id="cb1-142">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> postProbTicks <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {</span>
<span id="cb1-143">      <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">list</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> [<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.954245</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.954245</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-144">      <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">scale</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> postTestScaleLogOdds<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-145">      <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">fmt</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> expFmt</span>
<span id="cb1-146">  }<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-147"></span>
<span id="cb1-148">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> lrTicks   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {</span>
<span id="cb1-149">      <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">list</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> [<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-150">      <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">scale</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> logLikelihoodRatioScale<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-151">      <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">fmt</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> lrFmt</span>
<span id="cb1-152">  }<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-153"></span>
<span id="cb1-154">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> fmt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".3f"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-155"></span>
<span id="cb1-156">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addTicks</span>(ticks)</span>
<span id="cb1-157">  {</span>
<span id="cb1-158">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(sel) {</span>
<span id="cb1-159">          <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> gs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> sel</span>
<span id="cb1-160">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enterMany</span>(ticks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">list</span>)</span>
<span id="cb1-161">                  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-162">          gs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>)</span>
<span id="cb1-163">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d) { <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> ticks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(d)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> })</span>
<span id="cb1-164">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d) { <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> ticks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(d)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> })</span>
<span id="cb1-165">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb1-166">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"class"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"test-line"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-167">          gs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>)</span>
<span id="cb1-168">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d) { <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> ticks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(d)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> })</span>
<span id="cb1-169">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>)</span>
<span id="cb1-170">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"class"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tick-label"</span>)</span>
<span id="cb1-171">              <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">text</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d) { <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> ticks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fmt</span>(d)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> })<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-172">      }<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-173">  }</span>
<span id="cb1-174"></span>
<span id="cb1-175">  preTestLineG</span>
<span id="cb1-176">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-177">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">translate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>))</span>
<span id="cb1-178">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">callReturn</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addTicks</span>(preProbTicks))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-179"></span>
<span id="cb1-180">  lrLineG</span>
<span id="cb1-181">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-182">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">translate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>))</span>
<span id="cb1-183">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">callReturn</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addTicks</span>(lrTicks))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-184"></span>
<span id="cb1-185">  postTestLineG</span>
<span id="cb1-186">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-187">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">translate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>))</span>
<span id="cb1-188">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">callReturn</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addTicks</span>(postProbTicks))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-189"></span>
<span id="cb1-190">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> nomogramLine <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svgNode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>)</span>
<span id="cb1-191">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">preTestScaleLogOdds</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb1-192">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb1-193">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">postTestScaleLogOdds</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb1-194">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb1-195">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"class"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"test-line"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-196"></span>
<span id="cb1-197">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">updateLine</span>() {</span>
<span id="cb1-198">      nomogramLine<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> preTestHandle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-199">      nomogramLine<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> postTestHandle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-200">  }</span>
<span id="cb1-201"></span>
<span id="cb1-202">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dragAttrs</span>(sel) {</span>
<span id="cb1-203">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> sel<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb1-204">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>)</span>
<span id="cb1-205">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>)</span>
<span id="cb1-206">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cursor"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pointer"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-207">  }</span>
<span id="cb1-208"></span>
<span id="cb1-209">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> preTestHandle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svgNode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"circle"</span>)</span>
<span id="cb1-210">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">preTestScaleLogOdds</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb1-211">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cy"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb1-212">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">callReturn</span>(dragAttrs)</span>
<span id="cb1-213">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">call</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">drag</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drag"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">event</span>) {</span>
<span id="cb1-214">              <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">debugger</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-215">              d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">this</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">event</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-216">              <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> lrX <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Number</span>(lrHandle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-217">              <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> dx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> lrX <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">event</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-218">              postTestHandle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> lrX <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> dx)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-219">              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">updateLine</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-220">          }))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-221"></span>
<span id="cb1-222">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> lrHandle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svgNode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"circle"</span>)</span>
<span id="cb1-223">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">postTestScaleLogOdds</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">preTestScaleLogOdds</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span>
<span id="cb1-224">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cy"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>)</span>
<span id="cb1-225">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">callReturn</span>(dragAttrs)</span>
<span id="cb1-226">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">call</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">drag</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drag"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">event</span>) {</span>
<span id="cb1-227">              <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">debugger</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-228">              d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">this</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">event</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-229">              <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> ptX <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Number</span>(preTestHandle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-230">              <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> dx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">event</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> ptX<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-231">              postTestHandle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">event</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> dx)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-232">              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">updateLine</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-233">          }))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-234"></span>
<span id="cb1-235">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> postTestHandle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svgNode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"circle"</span>)</span>
<span id="cb1-236">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">postTestScaleLogOdds</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb1-237">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cy"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb1-238">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">callReturn</span>(dragAttrs)</span>
<span id="cb1-239">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">call</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">drag</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drag"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">event</span>) {</span>
<span id="cb1-240">              <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">debugger</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-241">              d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">this</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">event</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-242">              lrHandle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">event</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Number</span>(preTestHandle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span>))))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-243">              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">updateLine</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-244">          }))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-245">}</span></code></pre></div>
</details>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-1-1" data-nodetype="declaration">

</div>
</div>
</div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-1-2" data-nodetype="expression">

</div>
</div>
</div>
</div>


<!-- -->



<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-casscells1978interpretation" class="csl-entry">
Casscells, Ward, Arno Schoenberger, and Thomas B Graboys. 1978. <span>“Interpretation by Physicians of Clinical Laboratory Results.”</span> <em>New England Journal of Medicine</em> 299 (18): 999–1001.
</div>
<div id="ref-letter1975nomogram" class="csl-entry">
Fagan, T. J. 1975. <span>“Nomogram for Bayes Theorem.”</span> <em>N Engl J Med</em> 293 (5): 257.
</div>
<div id="ref-enwiki:1085193589" class="csl-entry">
Wikipedia contributors. 2022. <span>“Nomogram — <span>Wikipedia</span><span>,</span> the Free Encyclopedia.”</span> <a href="https://en.wikipedia.org/w/index.php?title=Nomogram&amp;oldid=1085193589">https://en.wikipedia.org/w/index.php?title=Nomogram&amp;oldid=1085193589</a>.
</div>
</div></section></div> ]]></description>
  <category>mathematics</category>
  <category>data-science</category>
  <guid>https://cscheid.net/v2/hacks/fagan-nomogram.html</guid>
  <pubDate>Sat, 14 Nov 2020 07:00:00 GMT</pubDate>
  <media:content url="https://cscheid.net/v2/images/fagan-nomogram.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Straight movement on circle</title>
  <link>https://cscheid.net/v2/hacks/straight-movement-on-circle.html</link>
  <description><![CDATA[ 




<p>Each individual circle moves along a straight line, but collectively, they look like a circle rolling inside a larger circle:</p>
<div id="main">

</div>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1" data-startfrom="14" data-source-offset="-0" style="background: #f1f3f5;"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 13;"><span id="cb1-14"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> { dom<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> time<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> math<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> svg <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> _svg } <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/src/cscheid/cscheid.js"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-15"></span>
<span id="cb1-16">{</span>
<span id="cb1-17">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#main"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"svg"</span>)</span>
<span id="cb1-18">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"viewBox"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0 0 600 600"</span>)</span>
<span id="cb1-19">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"100%"</span>)</span>
<span id="cb1-20">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"100%"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-21"></span>
<span id="cb1-22">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> scale <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">575</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-23"></span>
<span id="cb1-24">    svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"circle"</span>)</span>
<span id="cb1-25">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb1-26">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cy"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb1-27">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb1-28">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>)</span>
<span id="cb1-29">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>)</span>
<span id="cb1-30">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke-width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"3px"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-31"></span>
<span id="cb1-32">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">makeMovingCircles</span>(angles)</span>
<span id="cb1-33">    {</span>
<span id="cb1-34">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-35">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"circle"</span>)</span>
<span id="cb1-36">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(angles)</span>
<span id="cb1-37">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()</span>
<span id="cb1-38">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"circle"</span>)</span>
<span id="cb1-39">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span>
<span id="cb1-40">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cos</span>(math<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">radians</span>(d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>))</span>
<span id="cb1-41">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cy"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb1-42">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span>))</span>
<span id="cb1-43">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> _svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rotate</span>(d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-44">    }</span>
<span id="cb1-45"></span>
<span id="cb1-46">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">makeSupportingLines</span>(angles)</span>
<span id="cb1-47">    {</span>
<span id="cb1-48">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-49">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>)</span>
<span id="cb1-50">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(angles)</span>
<span id="cb1-51">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()</span>
<span id="cb1-52">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>)</span>
<span id="cb1-53">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb1-54">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>( <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb1-55">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb1-56">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb1-57">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gray"</span>)</span>
<span id="cb1-58">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>)</span>
<span id="cb1-59">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke-width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1px"</span>)</span>
<span id="cb1-60">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> _svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rotate</span>(d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-61">    }</span>
<span id="cb1-62"></span>
<span id="cb1-63">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> angles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map</span>(d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">360</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-64">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">makeSupportingLines</span>(angles)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-65">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> sel <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">makeMovingCircles</span>(angles)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-66"></span>
<span id="cb1-67">    dom<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">animate</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb1-68">        <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> t <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> time<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">elapsed</span>() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-69">        sel<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(</span>
<span id="cb1-70">            <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cos</span>(math<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">radians</span>(d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> t)) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-71">    })<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-72">}</span></code></pre></div>
</details>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-1-1" data-nodetype="declaration">

</div>
</div>
</div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-1-2" data-nodetype="expression">

</div>
</div>
</div>
</div>
<section id="acknowledgments" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgments">Acknowledgments</h2>
<p>As usual, found <a href="https://twitter.com/ZonePhysics/status/1190328863571808257">on twitter</a>. Apparently this is known as a <a href="https://en.wikipedia.org/wiki/Tusi_couple">Tusi couple</a>.</p>


<!-- -->

</section>

 ]]></description>
  <category>optical-illusion</category>
  <guid>https://cscheid.net/v2/hacks/straight-movement-on-circle.html</guid>
  <pubDate>Sat, 14 Nov 2020 07:00:00 GMT</pubDate>
  <media:content url="https://cscheid.net/v2/images/straight-movement-on-circle.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Error-Correcting Output Codes</title>
  <link>https://cscheid.net/v2/explainers/ecoc.html</link>
  <description><![CDATA[ 




<p>Often it will be the case that we can model a process we care about as two parties communicating with one another over a <em>noisy channel</em>. Sometimes this is very straightforward: if you’re sending the content of a website to a cellphone, the radio in the cellphone will need to be able to figure out when the message was garbled, and will need to figure out how to fix it. Surprisingly, some techniques in data science also benefit from this change in perspective.</p>
<p>Consider the problem of creating a classifier that can distinguish between more than two classes. We could try to solve this problem from first principles and build that classifier “from nothing”. But if we already know how to build binary classifiers, then we could try to turn the problem of multiple classification into (many instances of) binary classification. The usual way of doing this are called “OVA”, and “AVA”], but there’s a different method that sometimes works better, is elegant, simple to explain, and connects directly to the idea of two parties communicating over a noisy channel.</p>
<section id="prelude-binary-tree-reductions" class="level2">
<h2 class="anchored" data-anchor-id="prelude-binary-tree-reductions">Prelude: Binary-tree reductions</h2>
<p>Let’s first introduce a slightly different, but very simple reduction. Let’s work, for now, with the case of an 8-class problem, so the actual class to be predicted is one of <code>0</code>, <code>1</code>, <code>2</code>, <code>3</code>, <code>4</code>, <code>5</code>, <code>6</code>, or <code>7</code>. What we will do is create a binary tree of decisions, where we will train a binary classifier for each of the nodes. The decisions of each classifier will determine the path that we will walk down the tree, and downstream branches will progressively narrow the set of possible choices. The leaves of this tree represent single classes, and the decision of the overall classifier.</p>
<p>Graphically, it looks like this:</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://cscheid.net/v2/explainers/ecoc-binary-tree.png" class="img-fluid figure-img"></p>
<figcaption>A binary tree to convert single-class predictors into multi-class predictors.</figcaption>
</figure>
</div>
<p>If you compare this scheme to the OVA and AVA ideas, you can notice a few similarities and a few differences.</p>
<p>First, the number of classifiers you need to train in this scheme is comparable to that of OVA (in a binary tree with <img src="https://latex.codecogs.com/png.latex?k"> leaves, there are always <img src="https://latex.codecogs.com/png.latex?k-1"> nodes).</p>
<p>In OVA, all classifiers are unbalanced, in that you’re training “class-<img src="https://latex.codecogs.com/png.latex?i"> vs.&nbsp;class-not-<img src="https://latex.codecogs.com/png.latex?i">” subproblems. Here, your classification problems are all balanced. The leaves of the binary tree classifier are identical to some of the AVA classifiers, but the internal nodes combine multiple classes. This can be both good and bad: it’s bad in that if you have multiple classes that look very different from one another, you’ll be trying to “teach your classifier more than one thing at once”. That’s not great. But if the classes in the same side of the internal nodes are similar enough, then combining them means that the training process for that node will be able to “share knowledge from its lessons”. And that’s a good thing.</p>
<p>Unlike OVA or AVA, the number of decisions you need to make at test time is quite small. Here, the path from the tree root to a leaf has <img src="https://latex.codecogs.com/png.latex?O(%5Clog%20k)"> nodes, while OVA needs <img src="https://latex.codecogs.com/png.latex?O(k)"> classifiers, and AVA, <img src="https://latex.codecogs.com/png.latex?O(k%5E2)">. This means that if your binary classifiers achieve an error rate of <img src="https://latex.codecogs.com/png.latex?%5Cepsilon">, then you can trivially see that the multiclass classifier will achieve an error rate of <img src="https://latex.codecogs.com/png.latex?O(%5Clog%20k)%20%5Cepsilon">.</p>
</section>
<section id="reducing-the-number-of-base-classifiers" class="level2">
<h2 class="anchored" data-anchor-id="reducing-the-number-of-base-classifiers">Reducing the number of base classifiers</h2>
<p>Now let’s make things a little weird. Say that you think your base binary classifier procedure is so good, that it will be able to distinguish between <em>any</em> partition of classes from the original problem that you give it. What’s the minimum number of classifiers you have to train? It is easy to see what that number must be. If you think of the decision of the final multiclass classifier as producing a word in binary, then clearly we need <img src="https://latex.codecogs.com/png.latex?O(%5Clog_2%20k)"> binary digits to write out that word. But a binary digit is the best we can get out of a binary classifier, so we need <img src="https://latex.codecogs.com/png.latex?O(%5Clog_2%20k)"> of them as well.</p>
<p>This also clearly suggests the way to build the classifier: write out the multiple class labels in binary representation, and now the job of the <img src="https://latex.codecogs.com/png.latex?i">-th of <img src="https://latex.codecogs.com/png.latex?%5Clog_2%20k"> binary classifiers is to predict the <img src="https://latex.codecogs.com/png.latex?i">-th digit of that binary representation. This is the same thing as building, for each of the level of the trees in the above example, a <em>single classifier</em>, where that classifier predicts whether to take the branch on the left or the right.</p>
<p>In other words, for the same 8-class problem we had before, we build classifiers that distinguish between:</p>
<ul>
<li><code>0123</code> vs.&nbsp;<code>4567</code></li>
<li><code>0145</code> vs.&nbsp;<code>2367</code></li>
<li><code>0246</code> vs.&nbsp;<code>1357</code></li>
</ul>
<p>Notice how there’s only one class that’s unique along any possible set of decisions of the binary classifiers. Let’s call this the “binary transmission” method (TODO: find the actual name used in ML).</p>
</section>
<section id="the-magic-of-error-correction" class="level1">
<h1>The magic of error correction</h1>
<p>This is pretty neat, but it turns out that the best is still ahead of us! The main thing we will address now is that it’s not always the case that our classifiers will be correct. And unlike the case with AVA and OVA, base-level mistakes in the binary tree and binary transmission methods are always catastrophic.</p>
<p>The problem of transmitting information in the presence of noise has been deeply studied since the early 20th century. The most magical thing about changing perspectives is that it instantly gives us a lot of new tools to think about a problem. So what if we pretend that each binary classifier is sending its result along a telegraph, in which mistakes can happen along the way? Then, the problem of fixing a transmission mistake looks equivalent to the problem of making a classifier error. So, <em>if we can fix a transmission mistake even if every digit can fail, we might be able to fix a multiclassifier mistake, even if every binary classifier can fail!</em>.</p>
<p>In the following, we will look at a very simple error-correcting code. The <a href="http://hunch.net/~beygel/tournament.pdf">state of the art for error correcting in multiclass classifiers</a> is much more complicated than this, but the principle is the same.</p>
<p>The idea itself behind error correcting codes is simple. Say we want to transmit a word that can be one of <code>000</code>, <code>001</code>, <code>010</code>, <code>011</code>, <code>100</code>, <code>101</code>, <code>110</code>, or <code>111</code>. We will model a transmission error as flipping one of the bits of those words. If we send this representation directly, then any errors that happen in the transmission will become indistinguishable from a successful transmission of a different message. This is a problem, because we won’t even know when something bad happens. It needs to be possible for our communication process to know, by looking at the transmitted word, that something wrong happened. So there needs to be enough <em>room</em> in the space of possible messages for the case where “bad stuff happened”. This means that we will have to <em>encode</em> the word we want to send into a bigger space of possible transmissions, a space with more room.</p>
<p>In addition, in this new space of possible transmission, every codeword should be far away from one another (where we <a href="https://en.wikipedia.org/wiki/Hamming_distance">measure distance by flipping bits</a>, the same process that we assume was introducing mistakes), because we want to give every codeword a “safety cushion” for errors, so that if we get a bad transmission, there’s only one codeword nearby, so we will know how to correct that mistake.</p>
<p>There are simple error detection methods, like sending the same message three times. If any of the words disagree with one another, then we know a mistake happened somewhere (and we correct it by majority voting).</p>
<p>This, however, is not a very efficient code, and most importantly, it will not work in the case of multiclass classification! When sending messages on radio, each error happens (<a href="https://en.wikipedia.org/wiki/Burst_error">well, kinda</a>) independently of one another. But in our case, a mistake happens when a classifier does badly for a given example. So if we just try to “send the same digit three times”, it’ll be the case that if we make a mistake once, then we will make it three times! We need to come up with a better method. (Specifically, I will describe below the <a href="https://en.wikipedia.org/wiki/Hamming(7,4)">Hamming(7,4) code</a>.)</p>
<section id="lets-not-repeat-digits" class="level2">
<h2 class="anchored" data-anchor-id="lets-not-repeat-digits">Let’s not repeat digits</h2>
<p>The code I’m going to describe to you works on 4-bit words, so for now let’s pretend that our original problem had 16 classes instead of 8. The encoding process is itself very easy to describe. We send the 4-bit word into a 7-bit space:</p>
<ul>
<li><img src="https://latex.codecogs.com/png.latex?A%20=%20d%5C_1%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_2%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4"></li>
<li><img src="https://latex.codecogs.com/png.latex?B%20=%20d%5C_1%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_3%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4"></li>
<li><img src="https://latex.codecogs.com/png.latex?C%20=%20d%5C_2%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_3%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4"></li>
<li><img src="https://latex.codecogs.com/png.latex?D%20=%20d%5C_1"></li>
<li><img src="https://latex.codecogs.com/png.latex?E%20=%20d%5C_2"></li>
<li><img src="https://latex.codecogs.com/png.latex?F%20=%20d%5C_3"></li>
<li><img src="https://latex.codecogs.com/png.latex?G%20=%20d%5C_4"></li>
</ul>
<p>Here, <img src="https://latex.codecogs.com/png.latex?d%5C_1"> through <img src="https://latex.codecogs.com/png.latex?d%5C_4"> are the digits of the word we want to send. As we argued above, it must be the case that this code is redundant. Indeed, any valid word respects the following equations:</p>
<ul>
<li><img src="https://latex.codecogs.com/png.latex?A%5C%20%5Ctextrm%7Bxor%7D%5C%20D%5C%20%5Ctextrm%7Bxor%7D%5C%20E%5C%20%5Ctextrm%7Bxor%7D%5C%20G%20=%200"></li>
<li><img src="https://latex.codecogs.com/png.latex?B%5C%20%5Ctextrm%7Bxor%7D%5C%20D%5C%20%5Ctextrm%7Bxor%7D%5C%20F%5C%20%5Ctextrm%7Bxor%7D%5C%20G%20=%200"></li>
<li><img src="https://latex.codecogs.com/png.latex?C%5C%20%5Ctextrm%7Bxor%7D%5C%20E%5C%20%5Ctextrm%7Bxor%7D%5C%20F%5C%20%5Ctextrm%7Bxor%7D%5C%20G%20=%200"></li>
</ul>
<p>These equations are easy to prove: remember that <img src="https://latex.codecogs.com/png.latex?%5Ctextrm%7Bxor%7D"> is commutatitive and associative, and that <img src="https://latex.codecogs.com/png.latex?a%5C%20%5Ctextrm%7Bxor%7D%5C%20a%20=%200">. Moreover, the equations are also the key to making error detection work. Here’s a minor modification we will make. Let’s assume that an error can happen on any digit we send, so we replace <img src="https://latex.codecogs.com/png.latex?A"> with <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BA%7D">, etc:</p>
<ul>
<li><img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BA%7D%20=%20%5Cepsilon_A%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_1%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_2%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4"></li>
<li><img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BB%7D%20=%20%5Cepsilon_B%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_1%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_3%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4"></li>
<li><img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BC%7D%20=%20%5Cepsilon_C%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_2%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_3%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4"></li>
<li><img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BD%7D%20=%20%5Cepsilon_D%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_1"></li>
<li><img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BE%7D%20=%20%5Cepsilon_E%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_2"></li>
<li><img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BF%7D%20=%20%5Cepsilon_F%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_3"></li>
<li><img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BG%7D%20=%20%5Cepsilon_G%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4"></li>
</ul>
<p>Here, we use <img src="https://latex.codecogs.com/png.latex?%5Cepsilon%5C_A">, <img src="https://latex.codecogs.com/png.latex?%5Cepsilon%5C_B">, etc. to model errors in our transmission. The code we are describing here can only correct mistakes if only one of them happens at a time. That means that for every transmission, either <img src="https://latex.codecogs.com/png.latex?%5Cepsilon%5C_A%20=%20%5Cepsilon%5C_B%20=%20%5Ccdots%20=%200">, or a single one of the <img src="https://latex.codecogs.com/png.latex?%5Cepsilon"> variables is one and all the others are still zero.</p>
<p>This is where the magic happens. Let’s say <img src="https://latex.codecogs.com/png.latex?%5Cepsilon_A%20=%201">. Although it seems like it will be hard to figure out that something went wrong (since the 7-bit word we transmitted “looks fine”), let’s look at those three equations that we derived which describe the redundancy in the code. Now, consider their equivalents with <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BA%7D">, etc. I’m also giving each term a name now, <img src="https://latex.codecogs.com/png.latex?c%5C_0"> through <img src="https://latex.codecogs.com/png.latex?c%5C_2">:</p>
<ul>
<li><img src="https://latex.codecogs.com/png.latex?c%5C_0%20=%20%5Ctilde%7BA%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Ctilde%7BD%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Ctilde%7BE%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Ctilde%7BG%7D%20=%20%5Cepsilon%5C_%7BA%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Cepsilon%5C_%7BD%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Cepsilon%5C_%7BE%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Cepsilon%5C_%7BG%7D"></li>
<li><img src="https://latex.codecogs.com/png.latex?c%5C_1%20=%20%5Ctilde%7BB%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Ctilde%7BD%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Ctilde%7BF%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Ctilde%7BG%7D%20=%20%5Cepsilon%5C_%7BB%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Cepsilon%5C_%7BD%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Cepsilon%5C_%7BF%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Cepsilon%5C_%7BG%7D"></li>
<li><img src="https://latex.codecogs.com/png.latex?c%5C_2%20=%20%5Ctilde%7BC%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Ctilde%7BE%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Ctilde%7BF%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Ctilde%7BG%7D%20=%20%5Cepsilon%5C_%7BC%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Cepsilon%5C_%7BE%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Cepsilon%5C_%7BF%7D%5C%20%5Ctextrm%7Bxor%7D%5C%20%5Cepsilon%5C_%7BG%7D"></li>
</ul>
<p>Notice two very important things on the right hand sides: every error variable appears at least once, and no error variable was cancelled out from appearing more than once in the left-hand sides.</p>
<p>There’s also a less immediate property of these <img src="https://latex.codecogs.com/png.latex?c"> variables: <em>every possible mistake case creates a different configuration of <img src="https://latex.codecogs.com/png.latex?c%5C_0">, <img src="https://latex.codecogs.com/png.latex?c%5C_1">, and <img src="https://latex.codecogs.com/png.latex?c%5C_2"></em>! This is truly remarkable, and you should check it for yourself, by setting the values of <img src="https://latex.codecogs.com/png.latex?%5Cepsilon%5C_A"> through <img src="https://latex.codecogs.com/png.latex?%5Cepsilon%5C_G"> to 1. For example, you should be able to convince yourself that if <img src="https://latex.codecogs.com/png.latex?c%5C_0%20=%200">, <img src="https://latex.codecogs.com/png.latex?c%5C_1%20=%201">, and <img src="https://latex.codecogs.com/png.latex?c%5C_2%20=%201">, then it must be the case that <img src="https://latex.codecogs.com/png.latex?%5Cepsilon%5C_%7BF%7D%20=%201">, which means that the mistake happened on <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BF%7D">, which in turn means that all we have to do is flip <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BF%7D"> to obtain <img src="https://latex.codecogs.com/png.latex?F">, and all other digits must be correct! If all <img src="https://latex.codecogs.com/png.latex?c">s are zero, then no error happened. (Again, we are assuming that errors happen only one at a time. Fate is not always this kind.)</p>
</section>
<section id="now-to-turn-this-into-a-multiclass-reduction" class="level2">
<h2 class="anchored" data-anchor-id="now-to-turn-this-into-a-multiclass-reduction">Now to turn this into a multiclass reduction</h2>
<p>The final remarkable property of this error-correcting code is that each digit in the new transmission is formed by a particular combination of the digits in the original problem. Let’s think of the binary classification problems in the “binary transmission” reduction. (Here, I’ll slip into hexadecimal notation and call the 16 classes <code>0123456789abcdef</code>):</p>
<ul>
<li><img src="https://latex.codecogs.com/png.latex?d_1">: <tt>01234567&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt> vs.&nbsp;the negative: <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;89abcdef</tt></li>
<li><img src="https://latex.codecogs.com/png.latex?d_2">: <tt>0123&nbsp;&nbsp;&nbsp;&nbsp;89ab&nbsp;&nbsp;&nbsp;</tt> vs.&nbsp;the negative: <tt>&nbsp;&nbsp;&nbsp;&nbsp;4567&nbsp;&nbsp;&nbsp;&nbsp;cdef</tt></li>
<li><img src="https://latex.codecogs.com/png.latex?d_3">: <tt>01&nbsp;&nbsp;45&nbsp;&nbsp;89&nbsp;&nbsp;cd&nbsp;</tt> vs.&nbsp;the negative: <tt>&nbsp;&nbsp;23&nbsp;&nbsp;67&nbsp;&nbsp;ab&nbsp;&nbsp;ef</tt></li>
<li><img src="https://latex.codecogs.com/png.latex?d_4">: <tt>0&nbsp;2&nbsp;4&nbsp;6&nbsp;8&nbsp;a&nbsp;c&nbsp;e</tt> vs.&nbsp;the negative: <tt>&nbsp;1&nbsp;3&nbsp;5&nbsp;7&nbsp;9&nbsp;b&nbsp;d&nbsp;f</tt></li>
</ul>
<p>(The whitespace is there simply to make the logic more apparent.) These are our “base-digits” classifiers. The “checksum-digit” classifiers, that is, the redundant classifiers we will build to let us fix mistakes, will use the <img src="https://latex.codecogs.com/png.latex?%5Ctextrm%7Bxor%7D"> operation as well. Concretely speaking, the classifier for <img src="https://latex.codecogs.com/png.latex?d%5C_1%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_2%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4"> (that is, our transmitted digit <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BA%7D"> above) should return a positive label when <img src="https://latex.codecogs.com/png.latex?d%5C_1%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_2%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4%20=%201">, or equivalently, it should separate the classes <code>02579bce</code> from <code>13468adf</code>.</p>
<p>Take a moment to convince yourself of why that makes sense: that split separates the classes that appear in <img src="https://latex.codecogs.com/png.latex?d%5C_1">, <img src="https://latex.codecogs.com/png.latex?d%5C_2">, or <img src="https://latex.codecogs.com/png.latex?d%5C_4"> an odd number of times from those that appear there an even number of times. In other words, this classifier will “attempt to send 1” if <img src="https://latex.codecogs.com/png.latex?d%5C_1%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_2%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4%20=%201">, and “attempt to send 0” if <img src="https://latex.codecogs.com/png.latex?d%5C_1%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_2%5C%20%5Ctextrm%7Bxor%7D%5C%20d%5C_4%20=%0A0">, <em>exactly like our communication example!</em></p>
<p>Now, every time any one of our classifiers makes an isolated mistake, we will be able to spot it and fix it, at the expense of training only three more classifiers. And all of these classifiers are trained on different label distributions, and so we don’t run into the issue of repeated classification mistakes (like we would if we used the “repeat transmission” code).</p>
<p>Isn’t that amazing?</p>
</section>
</section>
<section id="further-reading" class="level1">
<h1>Further reading</h1>
<p>There are a number of details that have to be handled when actually deploying this strategy. The main one is that the choice on how to order the classes to create those splits is quite important, both because we need the individual classifiers to be good, and because we need digit errors to be relatively uncorrelated to one another.</p>
<p>In practice, what the literature suggests is to <em>invent a new custom code for every multiclass classification problem</em>. This is easier than it looks, and if you’re interested, then Dietterich and Bakiri’s <a href="https://arxiv.org/pdf/cs/9501101.pdf">seminal paper</a> is what you should read next. This technique is now known as ECOC (“error-correcting output codes”).</p>
<p>The question of whether ECOC’s are the best we can do remained open for a while, and although it’s still not completely settled, a (much more complicated) solution that combines error correction with the binary tournament idea from above gets pretty close to optimal. These are <a href="https://arxiv.org/abs/0902.3176">error-correcting tournaments</a>, proposed by Beygelzimer et al.&nbsp;I confess I don’t actually understand ECTs all that well, but the good news is that at least they’re implemented in <a href="https://github.com/VowpalWabbit/vowpal_wabbit">Vowpal Wabbit</a>. If each of the base classifiers achieves an average error rate of <img src="https://latex.codecogs.com/png.latex?%5Cepsilon">, error-correcting tournaments achieve a multiclass error bound of <img src="https://latex.codecogs.com/png.latex?2%20%5Cepsilon">. This is independent of the number of classes in the multiclass problem, which is quite incredible.</p>
<section id="notes" class="level2">
<h2 class="anchored" data-anchor-id="notes">Notes</h2>
<ul>
<li>The reason we can’t use the “repeat the same message more than once” trick is that we assumed we were always training the same classifier. If you have two binary classifiers for the same problem that both predict reasonably well, and whose predictions are relatively uncorrelated, then you can absolutely use this “repeat message” method. This turns out to work <a href="https://en.wikipedia.org/wiki/Bootstrap_aggregating">incredibly well in practice</a>!</li>
</ul>


<!-- -->

</section>
</section>

 ]]></description>
  <category>explainers</category>
  <category>data-science</category>
  <guid>https://cscheid.net/v2/explainers/ecoc.html</guid>
  <pubDate>Wed, 01 Jan 2020 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Multidimensional Scaling</title>
  <link>https://cscheid.net/v2/explainers/mds.html</link>
  <description><![CDATA[ 




<p>“Multidimensional Scaling” techniques turn measurements of similarities (or distances) into <strong>coordinates</strong> of points in a low-dimensional space, usually 2D of 3D.</p>
<section id="classical-mds" class="level2">
<h2 class="anchored" data-anchor-id="classical-mds">Classical MDS</h2>
<p>There are many variants of “multidimensional scaling”, with different assumptions on the measurements, and different ways to reconstruct the values. Here we will focus on the very simplest of them, typically known as “Classical” multidimensional scaling, or CMDS. For more, the best reference is Borg and Groenen’s Modern Multidimensional Scaling<sup>1</sup>.</p>
</section>
<section id="from-distances" class="level2">
<h2 class="anchored" data-anchor-id="from-distances">From distances</h2>
<p>Imagine that, instead of knowing the coordinates of a set of points, all you knew were the distance from each point to each other point. Intuitively, it seems like it should be possible to convert this information back into coordinates which respect the distances. Consider the simplest case of three points A, B, and C, and that we know that</p>
<p><img src="https://latex.codecogs.com/png.latex?%20%5Cbegin%7Baligned%7D%20d(A,B)%20&amp;=%203%20%5C%5C%20d(A,C)%20&amp;=%204%20%5C%5C%20d(B,C)%20&amp;=%205%20%5Cend%7Baligned%7D%20"></p>
<p>We instantly recognize those distances as forming a right triangle, and so a possible solution is <img src="https://latex.codecogs.com/png.latex?A%20=%20(0,0),%20B%20=%20(3,0),%20C%20=%20(0,%204)">. Note, however, that, there is more than one possible set of coordinates for that triangle. We could move it around the plane, we could rotate it, and we could flip it.</p>
<p>So, just remember that MDS generally will give <em>one</em> possible set of coordinates, instead of a unique one. But how does it do that?</p>
<p>Let’s start with the description of the algorithm:</p>
<ol type="1">
<li><img src="https://latex.codecogs.com/png.latex?D%20=%20(%7C%7CX_i%20-%20X_j%7C%7C%5E2)_%7Bij%7D">: let <img src="https://latex.codecogs.com/png.latex?D"> be a matrix that stores the <strong>squared</strong> distance from point <img src="https://latex.codecogs.com/png.latex?i"> to point <img src="https://latex.codecogs.com/png.latex?j"> (notice that we do not currently have the <img src="https://latex.codecogs.com/png.latex?X_i"> and <img src="https://latex.codecogs.com/png.latex?X_j"> vectors; we’re just using the notation to say what the entries of the matrix should store.</li>
<li><img src="https://latex.codecogs.com/png.latex?P%20=%20(-1/2)%20H%20D%20H">: let <img src="https://latex.codecogs.com/png.latex?P"> be a row- and column-centered version of <img src="https://latex.codecogs.com/png.latex?D">, multiplied by <img src="https://latex.codecogs.com/png.latex?-1/2"> (<img src="https://latex.codecogs.com/png.latex?H"> is the centering matrix, as described in the <a href="pca.html">PCA</a> section).</li>
<li>Let <img src="https://latex.codecogs.com/png.latex?P%20=%20U%20%5CLambda%20U%5ET">.</li>
<li>The coordinates of <img src="https://latex.codecogs.com/png.latex?X"> are given by the first few columns of <img src="https://latex.codecogs.com/png.latex?U%20%5CLambda%5E%7B1/2%7D">.</li>
</ol>
<p>The decision of how many coordinates to use for the MDS is similar to the decision of how many principal components to choose. As we go down the diagonal values of <img src="https://latex.codecogs.com/png.latex?%5CLambda">, the values will get closer to zero (and we assume that they are sorted from largest to smallest). We will usually drop some columns, which is the same as setting some values in <img src="https://latex.codecogs.com/png.latex?%5CLambda"> to zero. The smaller these non-zero values were, the more precise the result of the MDS will be (that is, the squared distance between <img src="https://latex.codecogs.com/png.latex?X_i"> and <img src="https://latex.codecogs.com/png.latex?X_j"> will become closer to the actual value in <img src="https://latex.codecogs.com/png.latex?D_%7Bij%7D">).</p>
<p>In fact, the easiest way to understand how CMDS works is to compare it directly to PCA. Specifically, let’s look at what happens if we started from an actual matrix <img src="https://latex.codecogs.com/png.latex?X"> from which to build <img src="https://latex.codecogs.com/png.latex?D">. In this case,</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Balign%7D%20D_%7Bij%7D%20&amp;=&amp;%20%7C%7C%20X_i%20-%20X_j%20%7C%7C%5E2%20%5C%5C%20D_%7Bij%7D%20&amp;=&amp;%20%5Clangle%20X_i%20-%20X_j,%20X_i%20-%20X_j%20%5Crangle%5C%5C%20D_%7Bij%7D%20&amp;=&amp;%20%5Clangle%20X_i,%20X_i%20%5Crangle%20+%20%5Clangle%20X_j,%20X_j%20%5Crangle%20-%202%20%5Clangle%20X_i,%20X_j%20%5Crangle.%20%5Cend%7Balign%7D"></p>
<p>So what we get is that every entry <img src="https://latex.codecogs.com/png.latex?i,%20j"> of the matrix <img src="https://latex.codecogs.com/png.latex?D"> can be represented by a sum of three terms. So we write the matrix <img src="https://latex.codecogs.com/png.latex?D"> as a sum of three matrices:</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Balign%7D%20D%20&amp;=&amp;%20(%5Clangle%20X_i,%20X_i%20%5Crangle)_%7Bij%7D%20+%20(%5Clangle%20X_j,%20X_j%20%5Crangle)_%7Bij%7D%20+%20(-2%20%5Clangle%20X_i,%20X_j%20%5Crangle)_%7Bij%7D%5C%5C%20D%20&amp;=&amp;%20A%20+%20B%20+%20C%5Cend%7Balign%7D"></p>
<p>Now we follow step 2 of the algorithm above, and let</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Balign%7D%20P%20&amp;=&amp;%20-1/2%20H%20D%20H%20%5C%5C%20P%20&amp;=&amp;%20-1/2%20H%20(A%20+%20B%20+%20C)%20H%20%5C%5C%20P%20&amp;=&amp;%20-(1/2)%20H%20A%20H%20-(1/2)%20H%20B%20H%20-(1/2)%20H%20C%20H%20%5Cend%7Balign%7D"></p>
<p>Now note that all of the columns of <img src="https://latex.codecogs.com/png.latex?A"> are identical, because the values only depend on the row index <img src="https://latex.codecogs.com/png.latex?i">. Similarly, all of the rows in <img src="https://latex.codecogs.com/png.latex?B"> are identical, because the values only depend on the column index <img src="https://latex.codecogs.com/png.latex?j">. This means that <img src="https://latex.codecogs.com/png.latex?HAH%20=%20HBH%20=%200">!, since column-centering <img src="https://latex.codecogs.com/png.latex?A"> will subtract the average column value; the analogous thing happens to row-centering <img src="https://latex.codecogs.com/png.latex?B">. As a result,</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Balign%7D%20P%20&amp;=&amp;%20-1/2%20H%20D%20H%20%5C%5C%20P%20&amp;=&amp;%20H%20(%5Clangle%20X_i,%20X_j)_%7Bij%7D%20%5Crangle%20H%20%5Cend%7Balign%7D"></p>
<p>So our <img src="https://latex.codecogs.com/png.latex?P"> matrix is now exactly equal to a centered matrix of inner products of <img src="https://latex.codecogs.com/png.latex?X">, even though we never used the inner products directly – all we had access to was squared distances. So if we take <img src="https://latex.codecogs.com/png.latex?P"> to be the matrix <img src="https://latex.codecogs.com/png.latex?M"> on step 3 of our <!-- [second PCA algorithm](pca.html#PCA%20%through%20%a%20matrix%20of%20inner%20products), --> we get to recover <img src="https://latex.codecogs.com/png.latex?X"> exactly! This is really neat.</p>
</section>
<section id="from-similarities" class="level2">
<h2 class="anchored" data-anchor-id="from-similarities">From similarities</h2>
<p>The same algorithm also applies directly when all we have access to is a notion of <strong>similarity</strong> between points. Here the idea is even simpler. Let’s say that we have a way to give a numerical value of similarity between points such that if two points are similar to each other, the value is relatively large, and if two points are relatively dissimilar, the value is relatively small. Then we can pretend that this value is “like an inner product”, create a matrix of similarities, center the matrix in both rows and columns, and just compute the PCA directly like above. This will actually recover good coordinates the respect the similarities!</p>
</section>
<section id="references" class="level1">
<h1>References</h1>


<!-- -->

</section>


<div id="quarto-appendix" class="default"><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>Borg, I. and Groenen, P.J.F. (2005). <a href="http://people.few.eur.nl/groenen/mmds/">Modern multidimensional scaling. 2nd edition</a>. New York: Springer.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>mathematics</category>
  <category>data-science</category>
  <guid>https://cscheid.net/v2/explainers/mds.html</guid>
  <pubDate>Wed, 01 Jan 2020 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Variations on the Hermann grid</title>
  <link>https://cscheid.net/v2/hacks/variations-on-the-hermann-grid.html</link>
  <description><![CDATA[ 




<p>The <a href="https://www.illusionsindex.org/i/hermann-grid">Hermann grid</a> is the prototypical example of the extinction illusion. Here we build a small variation of Figure 5 from <a href="http://journals.sagepub.com/doi/abs/10.1068/p2985">Ninio and Stevens’s Variations on the Hermann Grid: An Extinction Illusion</a>. There are equally many points on either half of the image: the animation simply moves the points vertically.</p>
<div id="main">

</div>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1" data-startfrom="16" data-source-offset="-0" style="background: #f1f3f5;"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 15;"><span id="cb1-16"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> { svg <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> _svg } <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/src/cscheid/cscheid.js"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-17"></span>
<span id="cb1-18">{</span>
<span id="cb1-19">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#main"</span>)</span>
<span id="cb1-20">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"svg"</span>)</span>
<span id="cb1-21">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>)</span>
<span id="cb1-22">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-23"></span>
<span id="cb1-24">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addLineGrid</span>(parent)</span>
<span id="cb1-25">    {</span>
<span id="cb1-26">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> parent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-27">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>)</span>
<span id="cb1-28">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>))</span>
<span id="cb1-29">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()</span>
<span id="cb1-30">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"line"</span>)</span>
<span id="cb1-31">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb1-32">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">900</span>)</span>
<span id="cb1-33">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>)</span>
<span id="cb1-34">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>)</span>
<span id="cb1-35">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gray"</span>)</span>
<span id="cb1-36">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke-width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"5px"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-37">    }</span>
<span id="cb1-38"></span>
<span id="cb1-39">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// ugly</span></span>
<span id="cb1-40">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addLineGrid</span>(svg)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(320, 320) rotate(90)  translate(-320, -320)"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-41">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addLineGrid</span>(svg)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(320, 320) rotate(30)  translate(-320, -320)"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-42">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addLineGrid</span>(svg)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(320, 320) rotate(150) translate(-320, -320)"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-43"></span>
<span id="cb1-44">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addPoints</span>(parent)</span>
<span id="cb1-45">    {</span>
<span id="cb1-46">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> parent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-47">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"circle"</span>)</span>
<span id="cb1-48">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>))</span>
<span id="cb1-49">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()</span>
<span id="cb1-50">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"circle"</span>)</span>
<span id="cb1-51">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"5px"</span>)</span>
<span id="cb1-52">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>)</span>
<span id="cb1-53">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>)</span>
<span id="cb1-54">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb1-55">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cy"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-56">    }</span>
<span id="cb1-57"></span>
<span id="cb1-58">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> gap <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-59"></span>
<span id="cb1-60">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> left <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>))</span>
<span id="cb1-61">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-62">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> _svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">translate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb1-63">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">call</span>(addPoints)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-64"></span>
<span id="cb1-65">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> right <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>))</span>
<span id="cb1-66">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-67">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> _svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">translate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">560</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span>gap))</span>
<span id="cb1-68">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">call</span>(addPoints)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-69"></span>
<span id="cb1-70">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">moveLeft</span>()</span>
<span id="cb1-71">    {</span>
<span id="cb1-72">    left<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-73">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">delay</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>)</span>
<span id="cb1-74">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>)</span>
<span id="cb1-75">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> _svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">translate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span>gap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb1-76">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-77">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">delay</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>)</span>
<span id="cb1-78">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>)</span>
<span id="cb1-79">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> _svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">translate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb1-80">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"end"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> moveLeft)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-81">    }</span>
<span id="cb1-82"></span>
<span id="cb1-83">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">moveRight</span>()</span>
<span id="cb1-84">    {</span>
<span id="cb1-85">    right<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-86">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">delay</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>)</span>
<span id="cb1-87">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>)</span>
<span id="cb1-88">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> _svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">translate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">560</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>gap<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb1-89">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-90">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">delay</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>)</span>
<span id="cb1-91">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>)</span>
<span id="cb1-92">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> _svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">translate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">560</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span>gap))</span>
<span id="cb1-93">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"end"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> moveRight)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-94">    }</span>
<span id="cb1-95"></span>
<span id="cb1-96">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">moveLeft</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-97">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">window</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setTimeout</span>(moveRight<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">750</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-98"></span>
<span id="cb1-99">}</span></code></pre></div>
</details>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-1-1" data-nodetype="declaration">

</div>
</div>
</div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-1-2" data-nodetype="expression">

</div>
</div>
</div>
</div>
<section id="acknowledgements" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgements">Acknowledgements</h2>
<p>I found out about the static version of this illusion <a href="https://twitter.com/chazfirestone/status/1049312925134020610">on twitter</a>.</p>


<!-- -->

</section>

 ]]></description>
  <category>optical-illusion</category>
  <guid>https://cscheid.net/v2/hacks/variations-on-the-hermann-grid.html</guid>
  <pubDate>Sat, 13 Oct 2018 07:00:00 GMT</pubDate>
  <media:content url="https://cscheid.net/v2/images/variations-on-the-hermann-grid.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Purple dots</title>
  <link>https://cscheid.net/v2/hacks/purple-dots.html</link>
  <description><![CDATA[ 




<p>If you keep your gaze focused at the black crosshairs, eventually the purple dots fade away and you start seeing an animated bright green dot instead.</p>
<div id="wrapper">

</div>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1" data-startfrom="14" data-source-offset="0" style="background: #f1f3f5;"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 13;"><span id="cb1-14">{</span>
<span id="cb1-15">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> svgMain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#wrapper"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"svg"</span>)</span>
<span id="cb1-16">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"viewBox"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0 0 600 600"</span>)</span>
<span id="cb1-17">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"100%"</span>)</span>
<span id="cb1-18">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"100%"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-19"></span>
<span id="cb1-20">    svgMain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"defs"</span>)</span>
<span id="cb1-21">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"filter"</span>)</span>
<span id="cb1-22">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"id"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blur1"</span>)</span>
<span id="cb1-23">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-50%"</span>)</span>
<span id="cb1-24">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-50%"</span>)</span>
<span id="cb1-25">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"200%"</span>)</span>
<span id="cb1-26">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"200%"</span>)</span>
<span id="cb1-27">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"feGaussianBlur"</span>)</span>
<span id="cb1-28">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"in"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SourceGraphic"</span>)</span>
<span id="cb1-29">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stdDeviation"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"5"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-30"></span>
<span id="cb1-31">    svgMain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svgMain</span>
<span id="cb1-32">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-33">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(300, 300)"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-34"></span>
<span id="cb1-35">    svgMain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-36">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"path"</span>)</span>
<span id="cb1-37">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>)</span>
<span id="cb1-38">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>)</span>
<span id="cb1-39">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"d"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"M -20 0 L 20 0 M 0 -20 L 0 20"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-40"></span>
<span id="cb1-41">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> nPoints <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-42">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span> angles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> nPoints)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map</span>((a) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> (a <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> nPoints) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-43"></span>
<span id="cb1-44">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> circles <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svgMain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-45">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"circle"</span>)</span>
<span id="cb1-46">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(angles)</span>
<span id="cb1-47">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()</span>
<span id="cb1-48">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"circle"</span>)</span>
<span id="cb1-49">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>)</span>
<span id="cb1-50">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">style</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"filter"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"url(#blur1)"</span>)</span>
<span id="cb1-51">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> (d) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cos</span>(d) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">210</span>)</span>
<span id="cb1-52">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cy"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> (d) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sin</span>(d) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">210</span>)</span>
<span id="cb1-53">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-54"></span>
<span id="cb1-55">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">startLoop</span>(d) {</span>
<span id="cb1-56">    d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">this</span>)</span>
<span id="cb1-57">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-58">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>)</span>
<span id="cb1-59">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">style</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"opacity"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb1-60">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-61">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>)</span>
<span id="cb1-62">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">style</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"opacity"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb1-63">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-64">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">delay</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">700</span>)</span>
<span id="cb1-65">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"end"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> startLoop)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-66">    }</span>
<span id="cb1-67"></span>
<span id="cb1-68">    circles<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-69">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">delay</span>((d) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> (d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>)</span>
<span id="cb1-70">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"end"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> startLoop)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-71">}</span></code></pre></div>
</details>
<div class="cell-output cell-output-display">
<div id="ojs-cell-1" data-nodetype="expression">

</div>
</div>
</div>
<section id="acknowledgements" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgements">Acknowledgements</h2>
<p>I tried to track down the original discoverer of this one but ultimately failed; it seems at this point to be folklore.</p>


<!-- -->

</section>

 ]]></description>
  <category>optical-illusion</category>
  <guid>https://cscheid.net/v2/hacks/purple-dots.html</guid>
  <pubDate>Thu, 27 Sep 2018 07:00:00 GMT</pubDate>
  <media:content url="https://cscheid.net/v2/images/purple-dots.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Ring with rotating gap</title>
  <link>https://cscheid.net/v2/hacks/ring-gap.html</link>
  <description><![CDATA[ 




<p>This is a continuous version of the <a href="../hacks/purple-dots.html">purple dots illusion</a>. Keep staring at the crosshairs. Eventually, instead of a white gap rotating, you’ll start seeing a bright band of the opponent color.</p>
<p>Incidentally, you’ll notice that this opponent color is quite bright - it in fact appears brighter than the white background of your display! This is because you’re experiencing a <a href="https://en.wikipedia.org/wiki/Impossible_color">Chimerical color</a>.</p>
<div id="main" style="height: 600px">

</div>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1" data-startfrom="21" data-source-offset="-0" style="background: #f1f3f5;"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 20;"><span id="cb1-21"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> { dom<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> time } <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/src/cscheid/cscheid.js"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-22"></span>
<span id="cb1-23">{</span>
<span id="cb1-24">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> canvasEl <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#main"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"canvas"</span>)</span>
<span id="cb1-25">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>)</span>
<span id="cb1-26">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-27"></span>
<span id="cb1-28">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> canvasCrosshair <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#main"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"canvas"</span>)</span>
<span id="cb1-29">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>)</span>
<span id="cb1-30">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>)</span>
<span id="cb1-31">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">style</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"position"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"relative"</span>)</span>
<span id="cb1-32">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">style</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"top"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-600px"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-33"></span>
<span id="cb1-34">    d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#main"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"div"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">style</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"600px"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-35"></span>
<span id="cb1-36">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> ctx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> dom<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setupCanvas</span>(canvasEl<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">node</span>())<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-37">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> xhCtx <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> dom<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setupCanvas</span>(canvasCrosshair<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">node</span>())<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-38"></span>
<span id="cb1-39">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// crosshairs</span></span>
<span id="cb1-40">    xhCtx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fillStyle</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rgba(0,0,0,0)"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-41">    xhCtx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fillRect</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-42">    xhCtx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strokeStyle</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-43">    xhCtx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lineWidth</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> ctx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpr</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-44">    xhCtx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">beginPath</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-45">    xhCtx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">moveTo</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">280</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-46">    xhCtx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lineTo</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">320</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-47">    xhCtx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">moveTo</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">280</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-48">    xhCtx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lineTo</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">320</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-49">    xhCtx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stroke</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-50"></span>
<span id="cb1-51">    canvasEl<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">node</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">style</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">filter</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blur(10px)"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-52"></span>
<span id="cb1-53">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tick</span>()</span>
<span id="cb1-54">    {</span>
<span id="cb1-55">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> now <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> time<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">elapsed</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-56"></span>
<span id="cb1-57">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// wipe</span></span>
<span id="cb1-58">    ctx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fillStyle</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-59">    ctx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fillRect</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-60"></span>
<span id="cb1-61">    ctx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lineWidth</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> ctx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpr</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-62"></span>
<span id="cb1-63">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> nSteps <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~~</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-64">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> radius <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-65">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> xScale <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">550</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-66">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> yScale <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">550</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-67"></span>
<span id="cb1-68">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>nSteps<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>i) {</span>
<span id="cb1-69">        <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> angleBeg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> nSteps) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-70">        <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> angleEnd <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ((i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> nSteps) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-71">        <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> lerp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">interpolateLab</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(angleBeg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">180</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-72"></span>
<span id="cb1-73">        <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> gapCenterAngle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> now <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span> (<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-74">        <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> sigma2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-75">        <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> weight <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(</span>
<span id="cb1-76">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pow</span>(gapCenterAngle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> angleBeg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> sigma2)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-77">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pow</span>((gapCenterAngle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> angleBeg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> sigma2)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-78">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pow</span>((gapCenterAngle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> angleBeg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> sigma2)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-79">        )<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-80"></span>
<span id="cb1-81">        ctx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strokeStyle</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">String</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lerp</span>(weight))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-82">        ctx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">beginPath</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-83">        ctx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">moveTo</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xScale</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cos</span>(angleBeg))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">yScale</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sin</span>(angleBeg)))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-84">        ctx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lineTo</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xScale</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cos</span>(angleEnd))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">yScale</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sin</span>(angleEnd)))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-85">        ctx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stroke</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-86">    }</span>
<span id="cb1-87"></span>
<span id="cb1-88">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">window</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">requestAnimationFrame</span>(tick)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-89">    }</span>
<span id="cb1-90"></span>
<span id="cb1-91">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tick</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-92">}</span></code></pre></div>
</details>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-1-1" data-nodetype="declaration">

</div>
</div>
</div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-1-2" data-nodetype="expression">

</div>
</div>
</div>
</div>
<section id="acknowledgements" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgements">Acknowledgements</h2>
<p>I’m sure this has been discovered before, but I came up with this particular version.</p>


<!-- -->

</section>

 ]]></description>
  <category>optical-illusion</category>
  <guid>https://cscheid.net/v2/hacks/ring-gap.html</guid>
  <pubDate>Thu, 27 Sep 2018 07:00:00 GMT</pubDate>
  <media:content url="https://cscheid.net/v2/images/ring-with-rotating-gap.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Curvature Blindness</title>
  <link>https://cscheid.net/v2/hacks/curvature-blindness.html</link>
  <description><![CDATA[ 




<p>Over a gray background, some of the wiggly lines appear much more triangular in shape than they do over a white or black background.</p>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1" data-startfrom="11" data-source-offset="0" style="background: #f1f3f5;"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 10;"><span id="cb1-11">{</span>
<span id="cb1-12">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> svgEl <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">html</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">`&lt;svg viewBox="0 0 600 600" width="100%" height="100%"&gt;&lt;/svg&gt;`</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-13"></span>
<span id="cb1-14">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(svgEl)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-15"></span>
<span id="cb1-16">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> lst <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-17"></span>
<span id="cb1-18">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> xScale <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">PI</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-19">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> yScale <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-20"></span>
<span id="cb1-21">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> line <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">line</span>()</span>
<span id="cb1-22">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">x</span>(d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> d)</span>
<span id="cb1-23">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">y</span>(d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">yScale</span>(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sin</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xScale</span>(d))))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-24"></span>
<span id="cb1-25">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> colors <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>)]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-26"></span>
<span id="cb1-27">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addWiggles</span>(sel) {</span>
<span id="cb1-28">    sel<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-29">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>))</span>
<span id="cb1-30">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()</span>
<span id="cb1-31">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-32">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> (d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(0, "</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>)</span>
<span id="cb1-33">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"path"</span>)</span>
<span id="cb1-34">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d) {</span>
<span id="cb1-35">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">===</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb1-36">          <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map</span>(d2 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(d2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  (d2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-37">        } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb1-38">          <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map</span>(d2 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(d2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> (d2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-39">        }</span>
<span id="cb1-40">      })</span>
<span id="cb1-41">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()</span>
<span id="cb1-42">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"path"</span>)</span>
<span id="cb1-43">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> (d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> colors[i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb1-44">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>)</span>
<span id="cb1-45">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"stroke-width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2px"</span>)</span>
<span id="cb1-46">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"d"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">line</span>(d))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-47">  }</span>
<span id="cb1-48"></span>
<span id="cb1-49">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">const</span> backgroundRhombi <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-50"></span>
<span id="cb1-51">  backgroundRhombi<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"path"</span>)</span>
<span id="cb1-52">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>))</span>
<span id="cb1-53">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"d"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"M 300 0 L 900 0 L 300 600 L -300 600 Z"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-54">  backgroundRhombi<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"path"</span>)</span>
<span id="cb1-55">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb1-56">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"d"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"M 900 0 L 1500 0 L 900 600 L 300 600 Z"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-57">  backgroundRhombi<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"path"</span>)</span>
<span id="cb1-58">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>))</span>
<span id="cb1-59">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"d"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"M 1500 0 L 2100 0 L 1500 600 L 900 600 Z"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-60"></span>
<span id="cb1-61">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addWiggles</span>(svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-62">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">addWiggles</span>(svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(0, 10)"</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-63"></span>
<span id="cb1-64">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">move</span>() {</span>
<span id="cb1-65">    backgroundRhombi<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(300,0)"</span>)</span>
<span id="cb1-66">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-67">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ease</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">easeLinear</span>)</span>
<span id="cb1-68">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15000</span>)</span>
<span id="cb1-69">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(-300,0)"</span>)</span>
<span id="cb1-70">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"end"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() {</span>
<span id="cb1-71">        d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">this</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-72">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ease</span>(d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">easeLinear</span>)</span>
<span id="cb1-73">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15000</span>)</span>
<span id="cb1-74">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(300,0)"</span>)</span>
<span id="cb1-75">          <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"end"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> move)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-76">      })<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-77">  }</span>
<span id="cb1-78"></span>
<span id="cb1-79">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">move</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-80">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> svgEl<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-81">}</span></code></pre></div>
</details>
<div class="cell-output cell-output-display">
<div id="ojs-cell-1" data-nodetype="expression">

</div>
</div>
</div>
<section id="acknowledgments" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgments">Acknowledgments</h2>
<p>This one appears to be <a href="http://blogs.discovermagazine.com/neuroskeptic/2017/12/08/curvature-blindness-illusion/">quite new</a>, published <a href="https://www.ncbi.nlm.nih.gov/pubmed/29204264">in 2017 by K. Takahashi</a>.</p>


<!-- -->

</section>

 ]]></description>
  <category>optical-illusion</category>
  <guid>https://cscheid.net/v2/hacks/curvature-blindness.html</guid>
  <pubDate>Sun, 10 Dec 2017 07:00:00 GMT</pubDate>
  <media:content url="https://cscheid.net/v2/images/curvature-blindness.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Checkerboard and Crosses</title>
  <link>https://cscheid.net/v2/hacks/checkerboard-and-crosses.html</link>
  <description><![CDATA[ 




<p>The checkerboard stays straight throughout the animation.</p>
<div id="main">

</div>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1" data-startfrom="12" data-source-offset="0" style="background: #f1f3f5;"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 11;"><span id="cb1-12">{</span>
<span id="cb1-13">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> svg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#main"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"svg"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">800</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-14"></span>
<span id="cb1-15">    svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(0,0)"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-16">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cycleScroll</span>() {</span>
<span id="cb1-17">        svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>)</span>
<span id="cb1-18">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(0, 200)"</span>)</span>
<span id="cb1-19">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>)</span>
<span id="cb1-20">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate(0,0)"</span>)</span>
<span id="cb1-21">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"end"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> cycleScroll)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-22">    }</span>
<span id="cb1-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cycleScroll</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>       </span>
<span id="cb1-24"></span>
<span id="cb1-25">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">roundUp</span>(x) {</span>
<span id="cb1-26">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~~</span>(x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-27">    }<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-28"></span>
<span id="cb1-29">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> squaresData <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-30">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> xScale <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-31">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> yScale <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scaleLinear</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">domain</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>([<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>])<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-32">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>i) {</span>
<span id="cb1-33">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>j) {</span>
<span id="cb1-34">            squaresData<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">push</span>({</span>
<span id="cb1-35">                <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">x</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">y</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-36">                <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">color</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> (i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> j) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb1-37">            })<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-38">        }</span>
<span id="cb1-39">    }</span>
<span id="cb1-40">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> crossesData <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> []<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-41">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>i) {</span>
<span id="cb1-42">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>j) {</span>
<span id="cb1-43">            <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> c <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-44">            <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> vs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-45">            <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> vs2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-46">            crossesData<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">push</span>({</span>
<span id="cb1-47">                <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">x</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">y</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-48">                <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">color_1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> vs[c <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-49">                <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">color_2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> (i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> j) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-50">                <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">color_3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">Math</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">random</span>() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">?</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-51">                <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">color_4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> vs2[c <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>]</span>
<span id="cb1-52">            })<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-53">        }</span>
<span id="cb1-54">    }</span>
<span id="cb1-55"></span>
<span id="cb1-56">    svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)</span>
<span id="cb1-57">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rect"</span>)</span>
<span id="cb1-58">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(squaresData)</span>
<span id="cb1-59">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()</span>
<span id="cb1-60">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rect"</span>)</span>
<span id="cb1-61">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~~</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xScale</span>(d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x</span>))</span>
<span id="cb1-62">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~~</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">yScale</span>(d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y</span>))</span>
<span id="cb1-63">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"width"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">roundUp</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xScale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xScale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)))</span>
<span id="cb1-64">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"height"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">roundUp</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xScale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xScale</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)))</span>
<span id="cb1-65">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">?</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-66"></span>
<span id="cb1-67">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> crossesG <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svg<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"g"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-68">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> crosses <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> crossesG</span>
<span id="cb1-69">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"path"</span>)</span>
<span id="cb1-70">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(crossesData)</span>
<span id="cb1-71">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">enter</span>()</span>
<span id="cb1-72">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">append</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"path"</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-73"></span>
<span id="cb1-74">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> lightCross <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-75">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> darkCross <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>  d3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hcl</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-76"></span>
<span id="cb1-77">    crosses</span>
<span id="cb1-78">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"transform"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> (<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"translate("</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xScale</span>(d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">","</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">yScale</span>(d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>))</span>
<span id="cb1-79">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"d"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"M -2,-2  l 0,-6  l 2,-2  l 2,2  l 0,6  l 6,0  l 2,2  l -2,2  l -6,0  l 0,6  l -2,2 l -2,-2  l 0,-6  l -6,0  l -2,-2 l 2,-2"</span>)</span>
<span id="cb1-80">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color_1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">?</span> darkCross <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> lightCross)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-81"></span>
<span id="cb1-82">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">changeToAndThen</span>(f<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> next) {</span>
<span id="cb1-83">        crossesG<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">selectAll</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"path"</span>)</span>
<span id="cb1-84">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-85">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">delay</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>)</span>
<span id="cb1-86">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span>)</span>
<span id="cb1-87">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"opacity"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb1-88">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-89">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>)</span>
<span id="cb1-90">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fill"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> f)</span>
<span id="cb1-91">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transition</span>()</span>
<span id="cb1-92">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duration</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span>)</span>
<span id="cb1-93">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"opacity"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb1-94">            <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">on</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"end"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> (d<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">===</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">?</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">next</span>() <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">null</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-95">    }</span>
<span id="cb1-96"></span>
<span id="cb1-97">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cyclePatterns</span>() {</span>
<span id="cb1-98">        <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> accessors <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"color_1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"color_2"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"color_3"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"color_4"</span>]<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-99">        <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">var</span> fs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> accessors<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map</span>((accessor<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i) <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span></span>
<span id="cb1-100">                            (() <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">changeToAndThen</span>(d <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">=&gt;</span> d[accessor] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">?</span> darkCross <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> lightCross<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-101">                                                    fs[(i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>accessors<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length</span>])))<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-102">        fs[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-103">    }</span>
<span id="cb1-104"></span>
<span id="cb1-105">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cyclePatterns</span>()<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-106">}</span></code></pre></div>
</details>
<div class="cell-output cell-output-display">
<div id="ojs-cell-1" data-nodetype="expression">

</div>
</div>
</div>
<section id="acknowledgments" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgments">Acknowledgments</h2>
<p>(<a href="http://bigblueboo.tumblr.com/post/81390584151/fooled-ya-brain">Source</a>). Thanks, <a href="https://twitter.com/Peter_shirley">Pete</a>!.</p>


<!-- -->

</section>

 ]]></description>
  <category>optical-illusion</category>
  <guid>https://cscheid.net/v2/hacks/checkerboard-and-crosses.html</guid>
  <pubDate>Tue, 05 Dec 2017 07:00:00 GMT</pubDate>
  <media:content url="https://cscheid.net/v2/images/checkerboard-and-crosses.jpg" medium="image" type="image/jpeg"/>
</item>
</channel>
</rss>
