This commit is contained in:
dabreegster 2022-01-13 13:05:23 +00:00
parent 07713f357c
commit c3dd2510bb
19 changed files with 198 additions and 118 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `RESOLUTION_M` constant in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, RESOLUTION_M"><title>RESOLUTION_M in game::ltn::draw_cells - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc constant"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a href='../../../game/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><h2 class="location">Other items in<br><a href="../../index.html">game</a>::<wbr><a href="../index.html">ltn</a>::<wbr><a href="index.html">draw_cells</a></h2><div id="sidebar-vars" data-name="RESOLUTION_M" data-ty="constant" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Constant <a href="../../index.html">game</a>::<wbr><a href="../index.html">ltn</a>::<wbr><a href="index.html">draw_cells</a>::<wbr><a class="constant" href="#">RESOLUTION_M</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/game/ltn/draw_cells.rs.html#23" title="goto source code">[src]</a></span></h1><pre class="rust const"><code>const RESOLUTION_M: <a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.f64.html">f64</a> = 10.0;</code></pre></section><section id="search" class="content hidden"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="game" data-search-index-js="../../../search-index.js" data-search-js="../../../search.js"></div>
<script src="../../../main.js"></script>
</body></html>

View File

@ -1,3 +1,3 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `color_cells` fn in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, color_cells"><title>color_cells in game::ltn::draw_cells - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a href='../../../game/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><h2 class="location">Other items in<br><a href="../../index.html">game</a>::<wbr><a href="../index.html">ltn</a>::<wbr><a href="index.html">draw_cells</a></h2><div id="sidebar-vars" data-name="color_cells" data-ty="fn" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Function <a href="../../index.html">game</a>::<wbr><a href="../index.html">ltn</a>::<wbr><a href="index.html">draw_cells</a>::<wbr><a class="fn" href="#">color_cells</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/game/ltn/draw_cells.rs.html#169-192" title="goto source code">[src]</a></span></h1><pre class="rust fn"><code>fn color_cells(<br>&nbsp;&nbsp;&nbsp;&nbsp;num_cells: <a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;adjacencies: <a class="struct" href="https://doc.rust-lang.org/1.57.0/std/collections/hash/set/struct.HashSet.html" title="struct std::collections::hash::set::HashSet">HashSet</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.usize.html">usize</a><a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.tuple.html">)</a>&gt;<br>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.57.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Color&gt;</code></pre></section><section id="search" class="content hidden"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="game" data-search-index-js="../../../search-index.js" data-search-js="../../../search.js"></div>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `color_cells` fn in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, color_cells"><title>color_cells in game::ltn::draw_cells - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a href='../../../game/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><h2 class="location">Other items in<br><a href="../../index.html">game</a>::<wbr><a href="../index.html">ltn</a>::<wbr><a href="index.html">draw_cells</a></h2><div id="sidebar-vars" data-name="color_cells" data-ty="fn" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Function <a href="../../index.html">game</a>::<wbr><a href="../index.html">ltn</a>::<wbr><a href="index.html">draw_cells</a>::<wbr><a class="fn" href="#">color_cells</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/game/ltn/draw_cells.rs.html#192-215" title="goto source code">[src]</a></span></h1><pre class="rust fn"><code>fn color_cells(<br>&nbsp;&nbsp;&nbsp;&nbsp;num_cells: <a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.usize.html">usize</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;adjacencies: <a class="struct" href="https://doc.rust-lang.org/1.57.0/std/collections/hash/set/struct.HashSet.html" title="struct std::collections::hash::set::HashSet">HashSet</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.usize.html">usize</a><a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.tuple.html">)</a>&gt;<br>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.57.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Color&gt;</code></pre></section><section id="search" class="content hidden"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="game" data-search-index-js="../../../search-index.js" data-search-js="../../../search.js"></div>
<script src="../../../main.js"></script>
</body></html>

File diff suppressed because one or more lines are too long

View File

@ -1,6 +0,0 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Partition a neighborhoods boundary polygon based on the cells. Currently this discretizes space into a grid, so the results dont look perfect, but its fast. Also returns the color for each cell, so that adjacent cells have different colors."><meta name="keywords" content="rust, rustlang, rust-lang, draw_cells"><title>draw_cells in game::ltn::draw_cells - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a href='../../../game/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><h2 class="location">Other items in<br><a href="../../index.html">game</a>::<wbr><a href="../index.html">ltn</a>::<wbr><a href="index.html">draw_cells</a></h2><div id="sidebar-vars" data-name="draw_cells" data-ty="fn" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Function <a href="../../index.html">game</a>::<wbr><a href="../index.html">ltn</a>::<wbr><a href="index.html">draw_cells</a>::<wbr><a class="fn" href="#">draw_cells</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/game/ltn/draw_cells.rs.html#26-118" title="goto source code">[src]</a></span></h1><pre class="rust fn"><code>pub fn draw_cells(<br>&nbsp;&nbsp;&nbsp;&nbsp;map: &amp;<a class="struct" href="../../../map_model/struct.Map.html" title="struct map_model::Map">Map</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;neighborhood: &amp;<a class="struct" href="../struct.Neighborhood.html" title="struct game::ltn::Neighborhood">Neighborhood</a><br>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.tuple.html">(</a>GeomBatch, <a class="struct" href="https://doc.rust-lang.org/1.57.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Color&gt;<a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.tuple.html">)</a></code></pre><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Partition a neighborhoods boundary polygon based on the cells. Currently this discretizes
space into a grid, so the results dont look perfect, but its fast. Also returns the color for
each cell, so that adjacent cells have different colors.</p>
</div></details></section><section id="search" class="content hidden"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="game" data-search-index-js="../../../search-index.js" data-search-js="../../../search.js"></div>
<script src="../../../main.js"></script>
</body></html>

View File

@ -1,11 +1,8 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `draw_cells` mod in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, draw_cells"><title>game::ltn::draw_cells - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a href='../../../game/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><h2 class="location">Module draw_cells</h2><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#constants">Constants</a></li><li><a href="#functions">Functions</a></li></ul></div><div id="sidebar-vars" data-name="draw_cells" data-ty="mod" data-relpath="./"></div><script defer src="./sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">game</a>::<wbr><a href="../index.html">ltn</a>::<wbr><a class="mod" href="#">draw_cells</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/game/ltn/draw_cells.rs.html#1-192" title="goto source code">[src]</a></span></h1><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.COLORS.html" title="game::ltn::draw_cells::COLORS struct">COLORS</a></div><div class="item-right docblock-short"></div></div></div><h2 id="constants" class="section-header"><a href="#constants">Constants</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.CAR_FREE_COLOR.html" title="game::ltn::draw_cells::CAR_FREE_COLOR constant">CAR_FREE_COLOR</a></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.DISCONNECTED_COLOR.html" title="game::ltn::draw_cells::DISCONNECTED_COLOR constant">DISCONNECTED_COLOR</a></div><div class="item-right docblock-short"></div></div></div><h2 id="functions" class="section-header"><a href="#functions">Functions</a></h2>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `draw_cells` mod in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, draw_cells"><title>game::ltn::draw_cells - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a href='../../../game/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><h2 class="location">Module draw_cells</h2><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#constants">Constants</a></li><li><a href="#functions">Functions</a></li></ul></div><div id="sidebar-vars" data-name="draw_cells" data-ty="mod" data-relpath="./"></div><script defer src="./sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">game</a>::<wbr><a href="../index.html">ltn</a>::<wbr><a class="mod" href="#">draw_cells</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/game/ltn/draw_cells.rs.html#1-215" title="goto source code">[src]</a></span></h1><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.COLORS.html" title="game::ltn::draw_cells::COLORS struct">COLORS</a></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.RenderCells.html" title="game::ltn::draw_cells::RenderCells struct">RenderCells</a></div><div class="item-right docblock-short"></div></div></div><h2 id="constants" class="section-header"><a href="#constants">Constants</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.CAR_FREE_COLOR.html" title="game::ltn::draw_cells::CAR_FREE_COLOR constant">CAR_FREE_COLOR</a></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.DISCONNECTED_COLOR.html" title="game::ltn::draw_cells::DISCONNECTED_COLOR constant">DISCONNECTED_COLOR</a></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.RESOLUTION_M.html" title="game::ltn::draw_cells::RESOLUTION_M constant">RESOLUTION_M</a></div><div class="item-right docblock-short"></div></div></div><h2 id="functions" class="section-header"><a href="#functions">Functions</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.color_cells.html" title="game::ltn::draw_cells::color_cells fn">color_cells</a></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.diffusion.html" title="game::ltn::draw_cells::diffusion fn">diffusion</a></div><div class="item-right docblock-short"><p>Returns a set of adjacent indices. The pairs are symmetric (x, y) and (y, x) will both be
populated. Adjacency with boundary_marker doesnt count.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.draw_cells.html" title="game::ltn::draw_cells::draw_cells fn">draw_cells</a></div><div class="item-right docblock-short"><p>Partition a neighborhoods boundary polygon based on the cells. Currently this discretizes
space into a grid, so the results dont look perfect, but its fast. Also returns the color for
each cell, so that adjacent cells have different colors.</p>
</div></div></div></section><section id="search" class="content hidden"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="game" data-search-index-js="../../../search-index.js" data-search-js="../../../search.js"></div>
<script src="../../../main.js"></script>
</body></html>

View File

@ -1 +1 @@
initSidebarItems({"constant":[["CAR_FREE_COLOR",""],["DISCONNECTED_COLOR",""]],"fn":[["color_cells",""],["diffusion","Returns a set of adjacent indices. The pairs are symmetric (x, y) and (y, x) will both be populated. Adjacency with boundary_marker doesnt count."],["draw_cells","Partition a neighborhoods boundary polygon based on the cells. Currently this discretizes space into a grid, so the results dont look perfect, but its fast. Also returns the color for each cell, so that adjacent cells have different colors."]],"struct":[["COLORS",""]]});
initSidebarItems({"constant":[["CAR_FREE_COLOR",""],["DISCONNECTED_COLOR",""],["RESOLUTION_M",""]],"fn":[["color_cells",""],["diffusion","Returns a set of adjacent indices. The pairs are symmetric (x, y) and (y, x) will both be populated. Adjacency with boundary_marker doesnt count."]],"struct":[["COLORS",""],["RenderCells",""]]});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The build time in RFC2822, UTC."><meta name="keywords" content="rust, rustlang, rust-lang, BUILT_TIME_UTC"><title>BUILT_TIME_UTC in map_gui::tools::title_screen::built_info - Rust</title><link rel="stylesheet" type="text/css" href="../../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../../ayu.css" disabled ><script id="default-settings" ></script><script src="../../../../storage.js"></script><script src="../../../../crates.js"></script><noscript><link rel="stylesheet" href="../../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../../favicon.svg"><style type="text/css">#crate-search{background-image:url("../../../../down-arrow.svg");}</style></head><body class="rustdoc constant"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a href='../../../../map_gui/index.html'><div class='logo-container rust-logo'><img src='../../../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><h2 class="location">Other items in<br><a href="../../../index.html">map_gui</a>::<wbr><a href="../../index.html">tools</a>::<wbr><a href="../index.html">title_screen</a>::<wbr><a href="index.html">built_info</a></h2><div id="sidebar-vars" data-name="BUILT_TIME_UTC" data-ty="constant" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../../../../wheel.svg"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Constant <a href="../../../index.html">map_gui</a>::<wbr><a href="../../index.html">tools</a>::<wbr><a href="../index.html">title_screen</a>::<wbr><a href="index.html">built_info</a>::<wbr><a class="constant" href="#">BUILT_TIME_UTC</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../../../src/map_gui/home/runner/work/abstreet/abstreet/target/debug/build/map_gui-5b11ba30aa99b1f3/out/built.rs.html#78" title="goto source code">[src]</a></span></h1><pre class="rust const"><code>pub const BUILT_TIME_UTC: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.str.html">str</a> = r&quot;Wed, 12 Jan 2022 15:05:01 +0000&quot;;</code></pre><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The build time in RFC2822, UTC.</p>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The build time in RFC2822, UTC."><meta name="keywords" content="rust, rustlang, rust-lang, BUILT_TIME_UTC"><title>BUILT_TIME_UTC in map_gui::tools::title_screen::built_info - Rust</title><link rel="stylesheet" type="text/css" href="../../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../../ayu.css" disabled ><script id="default-settings" ></script><script src="../../../../storage.js"></script><script src="../../../../crates.js"></script><noscript><link rel="stylesheet" href="../../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../../favicon.svg"><style type="text/css">#crate-search{background-image:url("../../../../down-arrow.svg");}</style></head><body class="rustdoc constant"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a href='../../../../map_gui/index.html'><div class='logo-container rust-logo'><img src='../../../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><h2 class="location">Other items in<br><a href="../../../index.html">map_gui</a>::<wbr><a href="../../index.html">tools</a>::<wbr><a href="../index.html">title_screen</a>::<wbr><a href="index.html">built_info</a></h2><div id="sidebar-vars" data-name="BUILT_TIME_UTC" data-ty="constant" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../../../../wheel.svg"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Constant <a href="../../../index.html">map_gui</a>::<wbr><a href="../../index.html">tools</a>::<wbr><a href="../index.html">title_screen</a>::<wbr><a href="index.html">built_info</a>::<wbr><a class="constant" href="#">BUILT_TIME_UTC</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../../../../src/map_gui/home/runner/work/abstreet/abstreet/target/debug/build/map_gui-5b11ba30aa99b1f3/out/built.rs.html#78" title="goto source code">[src]</a></span></h1><pre class="rust const"><code>pub const BUILT_TIME_UTC: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.57.0/std/primitive.str.html">str</a> = r&quot;Thu, 13 Jan 2022 13:04:27 +0000&quot;;</code></pre><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The build time in RFC2822, UTC.</p>
</div></details></section><section id="search" class="content hidden"></section><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="map_gui" data-search-index-js="../../../../search-index.js" data-search-js="../../../../search.js"></div>
<script src="../../../../main.js"></script>
</body></html>

File diff suppressed because one or more lines are too long

View File

@ -394,13 +394,13 @@
<span class="ident"><span class="kw">super</span>::per_neighborhood::populate_world</span>(<span class="ident">ctx</span>, <span class="ident">app</span>, <span class="ident">neighborhood</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">world</span>, <span class="op">|</span><span class="ident">id</span><span class="op">|</span> <span class="ident">id</span>, <span class="number">0</span>);
<span class="kw">let</span> (<span class="ident">draw_areas</span>, <span class="ident">cell_colors</span>) <span class="op">=</span> <span class="ident"><span class="kw">super</span>::draw_cells::draw_cells</span>(<span class="ident">map</span>, <span class="ident">neighborhood</span>);
<span class="kw">let</span> <span class="ident">render_cells</span> <span class="op">=</span> <span class="ident"><span class="kw">super</span>::draw_cells::RenderCells::new</span>(<span class="ident">map</span>, <span class="ident">neighborhood</span>);
<span class="kw">if</span> <span class="ident">draw_cells_as_areas</span> {
<span class="ident">world</span>.<span class="ident">draw_master_batch</span>(<span class="ident">ctx</span>, <span class="ident">draw_areas</span>);
<span class="ident">world</span>.<span class="ident">draw_master_batch</span>(<span class="ident">ctx</span>, <span class="ident">render_cells</span>.<span class="ident">draw_grid</span>());
} <span class="kw">else</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">draw</span> <span class="op">=</span> <span class="ident">GeomBatch::new</span>();
<span class="kw">for</span> (<span class="ident">idx</span>, <span class="ident">cell</span>) <span class="kw">in</span> <span class="ident">neighborhood</span>.<span class="ident">cells</span>.<span class="ident">iter</span>().<span class="ident">enumerate</span>() {
<span class="kw">let</span> <span class="ident">color</span> <span class="op">=</span> <span class="ident">cell_colors</span>[<span class="ident">idx</span>].<span class="ident">alpha</span>(<span class="number">0.9</span>);
<span class="kw">let</span> <span class="ident">color</span> <span class="op">=</span> <span class="ident">render_cells</span>.<span class="ident">colors</span>[<span class="ident">idx</span>].<span class="ident">alpha</span>(<span class="number">0.9</span>);
<span class="kw">for</span> (<span class="ident">r</span>, <span class="ident">interval</span>) <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">cell</span>.<span class="ident">roads</span> {
<span class="kw">let</span> <span class="ident">road</span> <span class="op">=</span> <span class="ident">map</span>.<span class="ident">get_r</span>(<span class="kw-2">*</span><span class="ident">r</span>);
<span class="ident">draw</span>.<span class="ident">push</span>(
@ -422,7 +422,7 @@
<span class="comment">// Draw the borders of each cell</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">draw</span> <span class="op">=</span> <span class="ident">GeomBatch::new</span>();
<span class="kw">for</span> (<span class="ident">idx</span>, <span class="ident">cell</span>) <span class="kw">in</span> <span class="ident">neighborhood</span>.<span class="ident">cells</span>.<span class="ident">iter</span>().<span class="ident">enumerate</span>() {
<span class="kw">let</span> <span class="ident">color</span> <span class="op">=</span> <span class="ident">cell_colors</span>[<span class="ident">idx</span>];
<span class="kw">let</span> <span class="ident">color</span> <span class="op">=</span> <span class="ident">render_cells</span>.<span class="ident">colors</span>[<span class="ident">idx</span>];
<span class="kw">for</span> <span class="ident">i</span> <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">cell</span>.<span class="ident">borders</span> {
<span class="kw">if</span> <span class="ident">draw_borders_as_arrows</span> {
<span class="kw">let</span> <span class="ident">angles</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">Angle</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">cell</span>

View File

@ -190,9 +190,32 @@
<span id="190">190</span>
<span id="191">191</span>
<span id="192">192</span>
<span id="193">193</span>
<span id="194">194</span>
<span id="195">195</span>
<span id="196">196</span>
<span id="197">197</span>
<span id="198">198</span>
<span id="199">199</span>
<span id="200">200</span>
<span id="201">201</span>
<span id="202">202</span>
<span id="203">203</span>
<span id="204">204</span>
<span id="205">205</span>
<span id="206">206</span>
<span id="207">207</span>
<span id="208">208</span>
<span id="209">209</span>
<span id="210">210</span>
<span id="211">211</span>
<span id="212">212</span>
<span id="213">213</span>
<span id="214">214</span>
<span id="215">215</span>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::collections</span>::{<span class="ident">HashSet</span>, <span class="ident">VecDeque</span>};
<span class="kw">use</span> <span class="ident">geom</span>::{<span class="ident">Distance</span>, <span class="ident">Polygon</span>, <span class="ident">Pt2D</span>};
<span class="kw">use</span> <span class="ident">geom</span>::{<span class="ident">Bounds</span>, <span class="ident">Distance</span>, <span class="ident">Polygon</span>, <span class="ident">Pt2D</span>};
<span class="kw">use</span> <span class="ident">map_gui::tools::Grid</span>;
<span class="kw">use</span> <span class="ident">map_model::Map</span>;
<span class="kw">use</span> <span class="ident">widgetry</span>::{<span class="ident">Color</span>, <span class="ident">GeomBatch</span>};
@ -212,101 +235,124 @@
<span class="kw">const</span> <span class="ident">CAR_FREE_COLOR</span>: <span class="ident">Color</span> <span class="op">=</span> <span class="ident">Color::GREEN</span>;
<span class="kw">const</span> <span class="ident">DISCONNECTED_COLOR</span>: <span class="ident">Color</span> <span class="op">=</span> <span class="ident">Color::RED</span>;
<span class="doccomment">/// Partition a neighborhood&#39;s boundary polygon based on the cells. Currently this discretizes</span>
<span class="doccomment">/// space into a grid, so the results don&#39;t look perfect, but it&#39;s fast. Also returns the color for</span>
<span class="doccomment">/// each cell, so that adjacent cells have different colors.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">draw_cells</span>(<span class="ident">map</span>: <span class="kw-2">&amp;</span><span class="ident">Map</span>, <span class="ident">neighborhood</span>: <span class="kw-2">&amp;</span><span class="ident">Neighborhood</span>) -&gt; (<span class="ident">GeomBatch</span>, <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">Color</span><span class="op">&gt;</span>) {
<span class="kw">let</span> <span class="ident">boundary_polygon</span> <span class="op">=</span> <span class="ident">neighborhood</span>
.<span class="ident">orig_perimeter</span>
.<span class="ident">clone</span>()
.<span class="ident">to_block</span>(<span class="ident">map</span>)
.<span class="ident">unwrap</span>()
.<span class="ident">polygon</span>;
<span class="comment">// Make a 2D grid covering the polygon. Each tile in the grid contains a cell index, which will</span>
<span class="comment">// become a color by the end. None means no cell is assigned yet.</span>
<span class="kw">let</span> <span class="ident">bounds</span> <span class="op">=</span> <span class="ident">boundary_polygon</span>.<span class="ident">get_bounds</span>();
<span class="kw">let</span> <span class="ident">resolution_m</span> <span class="op">=</span> <span class="number">10.0</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">grid</span>: <span class="ident">Grid</span><span class="op">&lt;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">usize</span><span class="op">&gt;</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Grid::new</span>(
(<span class="ident">bounds</span>.<span class="ident">width</span>() <span class="op">/</span> <span class="ident">resolution_m</span>).<span class="ident">ceil</span>() <span class="kw">as</span> <span class="ident">usize</span>,
(<span class="ident">bounds</span>.<span class="ident">height</span>() <span class="op">/</span> <span class="ident">resolution_m</span>).<span class="ident">ceil</span>() <span class="kw">as</span> <span class="ident">usize</span>,
<span class="prelude-val">None</span>,
);
<span class="kw">const</span> <span class="ident">RESOLUTION_M</span>: <span class="ident">f64</span> <span class="op">=</span> <span class="number">10.0</span>;
<span class="comment">// Initially fill out the grid based on the roads in each cell</span>
<span class="kw">for</span> (<span class="ident">cell_idx</span>, <span class="ident">cell</span>) <span class="kw">in</span> <span class="ident">neighborhood</span>.<span class="ident">cells</span>.<span class="ident">iter</span>().<span class="ident">enumerate</span>() {
<span class="kw">for</span> (<span class="ident">r</span>, <span class="ident">interval</span>) <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">cell</span>.<span class="ident">roads</span> {
<span class="kw">let</span> <span class="ident">road</span> <span class="op">=</span> <span class="ident">map</span>.<span class="ident">get_r</span>(<span class="kw-2">*</span><span class="ident">r</span>);
<span class="comment">// Walk along the center line. We could look at the road&#39;s thickness and fill out</span>
<span class="comment">// points based on that, but the diffusion should take care of it.</span>
<span class="kw">for</span> (<span class="ident">pt</span>, <span class="kw">_</span>) <span class="kw">in</span> <span class="ident">road</span>
.<span class="ident">center_pts</span>
.<span class="ident">exact_slice</span>(<span class="ident">interval</span>.<span class="ident">start</span>, <span class="ident">interval</span>.<span class="ident">end</span>)
.<span class="ident">step_along</span>(<span class="ident">Distance::meters</span>(<span class="ident">resolution_m</span> <span class="op">/</span> <span class="number">2.0</span>), <span class="ident">Distance::ZERO</span>)
{
<span class="kw">let</span> <span class="ident">grid_idx</span> <span class="op">=</span> <span class="ident">grid</span>.<span class="ident">idx</span>(
((<span class="ident">pt</span>.<span class="ident">x</span>() <span class="op">-</span> <span class="ident">bounds</span>.<span class="ident">min_x</span>) <span class="op">/</span> <span class="ident">resolution_m</span>) <span class="kw">as</span> <span class="ident">usize</span>,
((<span class="ident">pt</span>.<span class="ident">y</span>() <span class="op">-</span> <span class="ident">bounds</span>.<span class="ident">min_y</span>) <span class="op">/</span> <span class="ident">resolution_m</span>) <span class="kw">as</span> <span class="ident">usize</span>,
);
<span class="comment">// If roads from two different cells are close enough to clobber originally, oh</span>
<span class="comment">// well?</span>
<span class="ident">grid</span>.<span class="ident">data</span>[<span class="ident">grid_idx</span>] <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">cell_idx</span>);
}
}
}
<span class="comment">// Also mark the boundary polygon, so we can prevent the diffusion from &quot;leaking&quot; outside the</span>
<span class="comment">// area. The grid covers the rectangular bounds of the polygon. Rather than make an enum with 3</span>
<span class="comment">// cases, just assign a new index to mean &quot;boundary.&quot;</span>
<span class="kw">let</span> <span class="ident">boundary_marker</span> <span class="op">=</span> <span class="ident">neighborhood</span>.<span class="ident">cells</span>.<span class="ident">len</span>();
<span class="kw">for</span> (<span class="ident">pt</span>, <span class="kw">_</span>) <span class="kw">in</span> <span class="ident">geom::PolyLine::unchecked_new</span>(<span class="ident">boundary_polygon</span>.<span class="ident">into_ring</span>().<span class="ident">into_points</span>())
.<span class="ident">step_along</span>(<span class="ident">Distance::meters</span>(<span class="ident">resolution_m</span> <span class="op">/</span> <span class="number">2.0</span>), <span class="ident">Distance::ZERO</span>)
{
<span class="comment">// TODO Refactor helpers to transform between map-space and the grid tiles. Possibly Grid</span>
<span class="comment">// should know about this.</span>
<span class="kw">let</span> <span class="ident">grid_idx</span> <span class="op">=</span> <span class="ident">grid</span>.<span class="ident">idx</span>(
((<span class="ident">pt</span>.<span class="ident">x</span>() <span class="op">-</span> <span class="ident">bounds</span>.<span class="ident">min_x</span>) <span class="op">/</span> <span class="ident">resolution_m</span>) <span class="kw">as</span> <span class="ident">usize</span>,
((<span class="ident">pt</span>.<span class="ident">y</span>() <span class="op">-</span> <span class="ident">bounds</span>.<span class="ident">min_y</span>) <span class="op">/</span> <span class="ident">resolution_m</span>) <span class="kw">as</span> <span class="ident">usize</span>,
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">RenderCells</span> {
<span class="doccomment">/// The grid only covers the boundary polygon of the neighborhood. The values are cell indices,</span>
<span class="doccomment">/// and `Some(num_cells)` marks the boundary of the neighborhood.</span>
<span class="ident">grid</span>: <span class="ident">Grid</span><span class="op">&lt;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">usize</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="doccomment">/// Colors per cell, such that adjacent cells are colored differently</span>
<span class="kw">pub</span> <span class="ident">colors</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">Color</span><span class="op">&gt;</span>,
<span class="doccomment">/// Bounds of the neighborhood boundary polygon</span>
<span class="ident">bounds</span>: <span class="ident">Bounds</span>,
<span class="doccomment">/// The number of cells, used as a sentinel value in the grid</span>
<span class="ident">boundary_marker</span>: <span class="ident">usize</span>,
}
<span class="doccomment">/// Partition a neighborhood&#39;s boundary polygon based on the cells. This discretizes</span>
<span class="doccomment">/// space into a grid, so the results don&#39;t look perfect, but it&#39;s fast.</span>
<span class="kw">impl</span> <span class="ident">RenderCells</span> {
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(<span class="ident">map</span>: <span class="kw-2">&amp;</span><span class="ident">Map</span>, <span class="ident">neighborhood</span>: <span class="kw-2">&amp;</span><span class="ident">Neighborhood</span>) -&gt; <span class="ident">RenderCells</span> {
<span class="kw">let</span> <span class="ident">boundary_polygon</span> <span class="op">=</span> <span class="ident">neighborhood</span>
.<span class="ident">orig_perimeter</span>
.<span class="ident">clone</span>()
.<span class="ident">to_block</span>(<span class="ident">map</span>)
.<span class="ident">unwrap</span>()
.<span class="ident">polygon</span>;
<span class="comment">// Make a 2D grid covering the polygon. Each tile in the grid contains a cell index, which</span>
<span class="comment">// will become a color by the end. None means no cell is assigned yet.</span>
<span class="kw">let</span> <span class="ident">bounds</span> <span class="op">=</span> <span class="ident">boundary_polygon</span>.<span class="ident">get_bounds</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">grid</span>: <span class="ident">Grid</span><span class="op">&lt;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">usize</span><span class="op">&gt;</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Grid::new</span>(
(<span class="ident">bounds</span>.<span class="ident">width</span>() <span class="op">/</span> <span class="ident">RESOLUTION_M</span>).<span class="ident">ceil</span>() <span class="kw">as</span> <span class="ident">usize</span>,
(<span class="ident">bounds</span>.<span class="ident">height</span>() <span class="op">/</span> <span class="ident">RESOLUTION_M</span>).<span class="ident">ceil</span>() <span class="kw">as</span> <span class="ident">usize</span>,
<span class="prelude-val">None</span>,
);
<span class="ident">grid</span>.<span class="ident">data</span>[<span class="ident">grid_idx</span>] <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">boundary_marker</span>);
}
<span class="kw">let</span> <span class="ident">adjacencies</span> <span class="op">=</span> <span class="ident">diffusion</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">grid</span>, <span class="ident">boundary_marker</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cell_colors</span> <span class="op">=</span> <span class="ident">color_cells</span>(<span class="ident">neighborhood</span>.<span class="ident">cells</span>.<span class="ident">len</span>(), <span class="ident">adjacencies</span>);
<span class="comment">// Color car-free cells in a special way</span>
<span class="kw">for</span> (<span class="ident">idx</span>, <span class="ident">cell</span>) <span class="kw">in</span> <span class="ident">neighborhood</span>.<span class="ident">cells</span>.<span class="ident">iter</span>().<span class="ident">enumerate</span>() {
<span class="kw">if</span> <span class="ident">cell</span>.<span class="ident">car_free</span> {
<span class="ident">cell_colors</span>[<span class="ident">idx</span>] <span class="op">=</span> <span class="ident">CAR_FREE_COLOR</span>;
} <span class="kw">else</span> <span class="kw">if</span> <span class="ident">cell</span>.<span class="ident">is_disconnected</span>() {
<span class="ident">cell_colors</span>[<span class="ident">idx</span>] <span class="op">=</span> <span class="ident">DISCONNECTED_COLOR</span>;
}
}
<span class="comment">// Just draw rectangles based on the grid</span>
<span class="comment">// TODO We should be able to generate actual polygons per cell using the contours crate</span>
<span class="comment">// TODO Also it&#39;d look nicer to render this &quot;underneath&quot; the roads and intersections, at the</span>
<span class="comment">// layer where areas are shown now</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">batch</span> <span class="op">=</span> <span class="ident">GeomBatch::new</span>();
<span class="kw">for</span> (<span class="ident">idx</span>, <span class="ident">value</span>) <span class="kw">in</span> <span class="ident">grid</span>.<span class="ident">data</span>.<span class="ident">iter</span>().<span class="ident">enumerate</span>() {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cell_idx</span>) <span class="op">=</span> <span class="ident">value</span> {
<span class="kw">if</span> <span class="kw-2">*</span><span class="ident">cell_idx</span> <span class="op">==</span> <span class="ident">boundary_marker</span> {
<span class="kw">continue</span>;
<span class="comment">// Initially fill out the grid based on the roads in each cell</span>
<span class="kw">for</span> (<span class="ident">cell_idx</span>, <span class="ident">cell</span>) <span class="kw">in</span> <span class="ident">neighborhood</span>.<span class="ident">cells</span>.<span class="ident">iter</span>().<span class="ident">enumerate</span>() {
<span class="kw">for</span> (<span class="ident">r</span>, <span class="ident">interval</span>) <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">cell</span>.<span class="ident">roads</span> {
<span class="kw">let</span> <span class="ident">road</span> <span class="op">=</span> <span class="ident">map</span>.<span class="ident">get_r</span>(<span class="kw-2">*</span><span class="ident">r</span>);
<span class="comment">// Walk along the center line. We could look at the road&#39;s thickness and fill out</span>
<span class="comment">// points based on that, but the diffusion should take care of it.</span>
<span class="kw">for</span> (<span class="ident">pt</span>, <span class="kw">_</span>) <span class="kw">in</span> <span class="ident">road</span>
.<span class="ident">center_pts</span>
.<span class="ident">exact_slice</span>(<span class="ident">interval</span>.<span class="ident">start</span>, <span class="ident">interval</span>.<span class="ident">end</span>)
.<span class="ident">step_along</span>(<span class="ident">Distance::meters</span>(<span class="ident">RESOLUTION_M</span> <span class="op">/</span> <span class="number">2.0</span>), <span class="ident">Distance::ZERO</span>)
{
<span class="kw">let</span> <span class="ident">grid_idx</span> <span class="op">=</span> <span class="ident">grid</span>.<span class="ident">idx</span>(
((<span class="ident">pt</span>.<span class="ident">x</span>() <span class="op">-</span> <span class="ident">bounds</span>.<span class="ident">min_x</span>) <span class="op">/</span> <span class="ident">RESOLUTION_M</span>) <span class="kw">as</span> <span class="ident">usize</span>,
((<span class="ident">pt</span>.<span class="ident">y</span>() <span class="op">-</span> <span class="ident">bounds</span>.<span class="ident">min_y</span>) <span class="op">/</span> <span class="ident">RESOLUTION_M</span>) <span class="kw">as</span> <span class="ident">usize</span>,
);
<span class="comment">// If roads from two different cells are close enough to clobber originally, oh</span>
<span class="comment">// well?</span>
<span class="ident">grid</span>.<span class="ident">data</span>[<span class="ident">grid_idx</span>] <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">cell_idx</span>);
}
}
<span class="kw">let</span> (<span class="ident">x</span>, <span class="ident">y</span>) <span class="op">=</span> <span class="ident">grid</span>.<span class="ident">xy</span>(<span class="ident">idx</span>);
<span class="kw">let</span> <span class="ident">tile_center</span> <span class="op">=</span> <span class="ident">Pt2D::new</span>(
<span class="ident">bounds</span>.<span class="ident">min_x</span> <span class="op">+</span> <span class="ident">resolution_m</span> <span class="op">*</span> (<span class="ident">x</span> <span class="kw">as</span> <span class="ident">f64</span> <span class="op">+</span> <span class="number">0.5</span>),
<span class="ident">bounds</span>.<span class="ident">min_y</span> <span class="op">+</span> <span class="ident">resolution_m</span> <span class="op">*</span> (<span class="ident">y</span> <span class="kw">as</span> <span class="ident">f64</span> <span class="op">+</span> <span class="number">0.5</span>),
);
<span class="ident">batch</span>.<span class="ident">push</span>(
<span class="ident">cell_colors</span>[<span class="kw-2">*</span><span class="ident">cell_idx</span>].<span class="ident">alpha</span>(<span class="number">0.5</span>),
<span class="ident">Polygon::rectangle_centered</span>(
<span class="ident">tile_center</span>,
<span class="ident">Distance::meters</span>(<span class="ident">resolution_m</span>),
<span class="ident">Distance::meters</span>(<span class="ident">resolution_m</span>),
),
}
<span class="comment">// Also mark the boundary polygon, so we can prevent the diffusion from &quot;leaking&quot; outside</span>
<span class="comment">// the area. The grid covers the rectangular bounds of the polygon. Rather than make an</span>
<span class="comment">// enum with 3 cases, just assign a new index to mean &quot;boundary.&quot;</span>
<span class="kw">let</span> <span class="ident">boundary_marker</span> <span class="op">=</span> <span class="ident">neighborhood</span>.<span class="ident">cells</span>.<span class="ident">len</span>();
<span class="kw">for</span> (<span class="ident">pt</span>, <span class="kw">_</span>) <span class="kw">in</span> <span class="ident">geom::PolyLine::unchecked_new</span>(<span class="ident">boundary_polygon</span>.<span class="ident">into_ring</span>().<span class="ident">into_points</span>())
.<span class="ident">step_along</span>(<span class="ident">Distance::meters</span>(<span class="ident">RESOLUTION_M</span> <span class="op">/</span> <span class="number">2.0</span>), <span class="ident">Distance::ZERO</span>)
{
<span class="comment">// TODO Refactor helpers to transform between map-space and the grid tiles. Possibly</span>
<span class="comment">// Grid should know about this.</span>
<span class="kw">let</span> <span class="ident">grid_idx</span> <span class="op">=</span> <span class="ident">grid</span>.<span class="ident">idx</span>(
((<span class="ident">pt</span>.<span class="ident">x</span>() <span class="op">-</span> <span class="ident">bounds</span>.<span class="ident">min_x</span>) <span class="op">/</span> <span class="ident">RESOLUTION_M</span>) <span class="kw">as</span> <span class="ident">usize</span>,
((<span class="ident">pt</span>.<span class="ident">y</span>() <span class="op">-</span> <span class="ident">bounds</span>.<span class="ident">min_y</span>) <span class="op">/</span> <span class="ident">RESOLUTION_M</span>) <span class="kw">as</span> <span class="ident">usize</span>,
);
<span class="ident">grid</span>.<span class="ident">data</span>[<span class="ident">grid_idx</span>] <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">boundary_marker</span>);
}
<span class="kw">let</span> <span class="ident">adjacencies</span> <span class="op">=</span> <span class="ident">diffusion</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">grid</span>, <span class="ident">boundary_marker</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cell_colors</span> <span class="op">=</span> <span class="ident">color_cells</span>(<span class="ident">neighborhood</span>.<span class="ident">cells</span>.<span class="ident">len</span>(), <span class="ident">adjacencies</span>);
<span class="comment">// Color car-free cells in a special way</span>
<span class="kw">for</span> (<span class="ident">idx</span>, <span class="ident">cell</span>) <span class="kw">in</span> <span class="ident">neighborhood</span>.<span class="ident">cells</span>.<span class="ident">iter</span>().<span class="ident">enumerate</span>() {
<span class="kw">if</span> <span class="ident">cell</span>.<span class="ident">car_free</span> {
<span class="ident">cell_colors</span>[<span class="ident">idx</span>] <span class="op">=</span> <span class="ident">CAR_FREE_COLOR</span>;
} <span class="kw">else</span> <span class="kw">if</span> <span class="ident">cell</span>.<span class="ident">is_disconnected</span>() {
<span class="ident">cell_colors</span>[<span class="ident">idx</span>] <span class="op">=</span> <span class="ident">DISCONNECTED_COLOR</span>;
}
}
<span class="ident">RenderCells</span> {
<span class="ident">grid</span>,
<span class="ident">colors</span>: <span class="ident">cell_colors</span>,
<span class="ident">bounds</span>,
<span class="ident">boundary_marker</span>,
}
}
(<span class="ident">batch</span>, <span class="ident">cell_colors</span>)
<span class="doccomment">/// Just draw rectangles based on the grid</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">draw_grid</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="ident">GeomBatch</span> {
<span class="comment">// TODO We should be able to generate actual polygons per cell using the contours crate</span>
<span class="comment">// TODO Also it&#39;d look nicer to render this &quot;underneath&quot; the roads and intersections, at the</span>
<span class="comment">// layer where areas are shown now</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">batch</span> <span class="op">=</span> <span class="ident">GeomBatch::new</span>();
<span class="kw">for</span> (<span class="ident">idx</span>, <span class="ident">value</span>) <span class="kw">in</span> <span class="self">self</span>.<span class="ident">grid</span>.<span class="ident">data</span>.<span class="ident">iter</span>().<span class="ident">enumerate</span>() {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cell_idx</span>) <span class="op">=</span> <span class="ident">value</span> {
<span class="kw">if</span> <span class="kw-2">*</span><span class="ident">cell_idx</span> <span class="op">==</span> <span class="self">self</span>.<span class="ident">boundary_marker</span> {
<span class="kw">continue</span>;
}
<span class="kw">let</span> (<span class="ident">x</span>, <span class="ident">y</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">grid</span>.<span class="ident">xy</span>(<span class="ident">idx</span>);
<span class="kw">let</span> <span class="ident">tile_center</span> <span class="op">=</span> <span class="ident">Pt2D::new</span>(
<span class="self">self</span>.<span class="ident">bounds</span>.<span class="ident">min_x</span> <span class="op">+</span> <span class="ident">RESOLUTION_M</span> <span class="op">*</span> (<span class="ident">x</span> <span class="kw">as</span> <span class="ident">f64</span> <span class="op">+</span> <span class="number">0.5</span>),
<span class="self">self</span>.<span class="ident">bounds</span>.<span class="ident">min_y</span> <span class="op">+</span> <span class="ident">RESOLUTION_M</span> <span class="op">*</span> (<span class="ident">y</span> <span class="kw">as</span> <span class="ident">f64</span> <span class="op">+</span> <span class="number">0.5</span>),
);
<span class="ident">batch</span>.<span class="ident">push</span>(
<span class="self">self</span>.<span class="ident">colors</span>[<span class="kw-2">*</span><span class="ident">cell_idx</span>].<span class="ident">alpha</span>(<span class="number">0.5</span>),
<span class="ident">Polygon::rectangle_centered</span>(
<span class="ident">tile_center</span>,
<span class="ident">Distance::meters</span>(<span class="ident">RESOLUTION_M</span>),
<span class="ident">Distance::meters</span>(<span class="ident">RESOLUTION_M</span>),
),
);
}
}
<span class="ident">batch</span>
}
}
<span class="doccomment">/// Returns a set of adjacent indices. The pairs are symmetric -- (x, y) and (y, x) will both be</span>

View File

@ -174,7 +174,7 @@
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">RUSTDOC_VERSION</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">r&quot;rustdoc 1.57.0 (f1edd0429 2021-11-29)&quot;</span>;
<span class="attribute">#[<span class="ident">doc</span><span class="op">=</span><span class="string">r#&quot;The build time in RFC2822, UTC.&quot;#</span>]</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">dead_code</span>)]</span>
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">BUILT_TIME_UTC</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">r&quot;Wed, 12 Jan 2022 15:05:01 +0000&quot;</span>;
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">BUILT_TIME_UTC</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">r&quot;Thu, 13 Jan 2022 13:04:27 +0000&quot;</span>;
<span class="attribute">#[<span class="ident">doc</span><span class="op">=</span><span class="string">r#&quot;The target architecture, given by `CARGO_CFG_TARGET_ARCH`.&quot;#</span>]</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">dead_code</span>)]</span>
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">CFG_TARGET_ARCH</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">r&quot;x86_64&quot;</span>;