This commit is contained in:
dabreegster 2020-12-06 03:00:03 +00:00
parent 9f85ee9914
commit 8a1e22b7d2
7 changed files with 69 additions and 36 deletions

View File

@ -1,6 +1,6 @@
<!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 `animation` mod in crate `experiment`."><meta name="keywords" content="rust, rustlang, rust-lang, animation"><title>experiment::animation - 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 src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg"> <!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 `animation` mod in crate `experiment`."><meta name="keywords" content="rust, rustlang, rust-lang, animation"><title>experiment::animation - 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 src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"> <link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../experiment/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Module animation</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li></ul></div><p class='location'><a href='../index.html'>experiment</a></p><script>window.sidebarCurrent = {name: 'animation', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><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><span class="help-button">?</span> <link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../experiment/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Module animation</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li></ul></div><p class='location'><a href='../index.html'>experiment</a></p><script>window.sidebarCurrent = {name: 'animation', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><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><span class="help-button">?</span>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><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/experiment/animation.rs.html#1-167' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>experiment</a>::<wbr><a class="mod" href=''>animation</a></span></h1><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2> <a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><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/experiment/animation.rs.html#1-182' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>experiment</a>::<wbr><a class="mod" href=''>animation</a></span></h1><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.Animation.html" title='experiment::animation::Animation struct'>Animation</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.Animator.html" title='experiment::animation::Animator struct'>Animator</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.SnowEffect.html" title='experiment::animation::SnowEffect struct'>SnowEffect</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.Snowflake.html" title='experiment::animation::Snowflake struct'>Snowflake</a></td><td class='docblock-short'></td></tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2> <table><tr class='module-item'><td><a class="struct" href="struct.Animation.html" title='experiment::animation::Animation struct'>Animation</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.Animator.html" title='experiment::animation::Animator struct'>Animator</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.SnowEffect.html" title='experiment::animation::SnowEffect struct'>SnowEffect</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.Snowflake.html" title='experiment::animation::Snowflake struct'>Snowflake</a></td><td class='docblock-short'></td></tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table><tr class='module-item'><td><a class="enum" href="enum.Effect.html" title='experiment::animation::Effect enum'>Effect</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "experiment";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html> <table><tr class='module-item'><td><a class="enum" href="enum.Effect.html" title='experiment::animation::Effect enum'>Effect</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "experiment";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>

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,5 +1,5 @@
<!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 `BUILT_TIME_UTC` constant in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, BUILT_TIME_UTC"><title>game::pregame::built_info::BUILT_TIME_UTC - 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 src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"> <!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 `BUILT_TIME_UTC` constant in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, BUILT_TIME_UTC"><title>game::pregame::built_info::BUILT_TIME_UTC - 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 src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"> <link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc constant"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#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"><p class='location'><a href='../../index.html'>game</a>::<wbr><a href='../index.html'>pregame</a>::<wbr><a href='index.html'>built_info</a></p><script>window.sidebarCurrent = {name: 'BUILT_TIME_UTC', ty: 'constant', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><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><span class="help-button">?</span> <link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc constant"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#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"><p class='location'><a href='../../index.html'>game</a>::<wbr><a href='../index.html'>pregame</a>::<wbr><a href='index.html'>built_info</a></p><script>window.sidebarCurrent = {name: 'BUILT_TIME_UTC', ty: 'constant', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><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><span class="help-button">?</span>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><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/home/runner/work/abstreet/abstreet/target/debug/build/game-f38555f90777146b/out/built.rs.html#49' title='goto source code'>[src]</a></span><span class='in-band'>Constant <a href='../../index.html'>game</a>::<wbr><a href='../index.html'>pregame</a>::<wbr><a href='index.html'>built_info</a>::<wbr><a class="constant" href=''>BUILT_TIME_UTC</a></span></h1><pre class='rust const'>pub const BUILT_TIME_UTC: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a> = &quot;Sun, 06 Dec 2020 02:12:17 +0000&quot;;</pre><div class='docblock'><p>The built-time in RFC2822, UTC</p> <a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><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/home/runner/work/abstreet/abstreet/target/debug/build/game-f38555f90777146b/out/built.rs.html#49' title='goto source code'>[src]</a></span><span class='in-band'>Constant <a href='../../index.html'>game</a>::<wbr><a href='../index.html'>pregame</a>::<wbr><a href='index.html'>built_info</a>::<wbr><a class="constant" href=''>BUILT_TIME_UTC</a></span></h1><pre class='rust const'>pub const BUILT_TIME_UTC: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a> = &quot;Sun, 06 Dec 2020 02:57:19 +0000&quot;;</pre><div class='docblock'><p>The built-time in RFC2822, UTC</p>
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "game";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html> </div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "game";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>

File diff suppressed because one or more lines are too long

View File

@ -168,6 +168,21 @@
<span id="165">165</span> <span id="165">165</span>
<span id="166">166</span> <span id="166">166</span>
<span id="167">167</span> <span id="167">167</span>
<span id="168">168</span>
<span id="169">169</span>
<span id="170">170</span>
<span id="171">171</span>
<span id="172">172</span>
<span id="173">173</span>
<span id="174">174</span>
<span id="175">175</span>
<span id="176">176</span>
<span id="177">177</span>
<span id="178">178</span>
<span id="179">179</span>
<span id="180">180</span>
<span id="181">181</span>
<span id="182">182</span>
</pre><div class="example-wrap"><pre class="rust "> </pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">rand</span>::{<span class="ident">Rng</span>, <span class="ident">SeedableRng</span>}; <span class="kw">use</span> <span class="ident">rand</span>::{<span class="ident">Rng</span>, <span class="ident">SeedableRng</span>};
<span class="kw">use</span> <span class="ident">rand_xorshift</span>::<span class="ident">XorShiftRng</span>; <span class="kw">use</span> <span class="ident">rand_xorshift</span>::<span class="ident">XorShiftRng</span>;
@ -274,7 +289,20 @@
<span class="kw">struct</span> <span class="ident">Snowflake</span> { <span class="kw">struct</span> <span class="ident">Snowflake</span> {
<span class="ident">start</span>: <span class="ident">Time</span>, <span class="ident">start</span>: <span class="ident">Time</span>,
<span class="ident">top_left</span>: <span class="ident">Pt2D</span>, <span class="ident">initial_pos</span>: <span class="ident">Pt2D</span>,
<span class="ident">fall_speed</span>: <span class="ident">f64</span>,
<span class="ident">swoop_period</span>: <span class="ident">f64</span>,
<span class="ident">max_swoop</span>: <span class="ident">f64</span>,
}
<span class="kw">impl</span> <span class="ident">Snowflake</span> {
<span class="kw">fn</span> <span class="ident">pos</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">time</span>: <span class="ident">Time</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Pt2D</span> {
<span class="kw">let</span> <span class="ident">arg</span> <span class="op">=</span>
(<span class="number">2.0</span> <span class="op">*</span> <span class="ident">std</span>::<span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span>) <span class="op">*</span> (<span class="ident">time</span> <span class="op">-</span> <span class="self">self</span>.<span class="ident">start</span>).<span class="ident">inner_seconds</span>() <span class="op">/</span> <span class="self">self</span>.<span class="ident">swoop_period</span>;
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">initial_pos</span>.<span class="ident">x</span>() <span class="op">+</span> <span class="self">self</span>.<span class="ident">max_swoop</span> <span class="op">*</span> <span class="ident">arg</span>.<span class="ident">cos</span>();
<span class="kw">let</span> <span class="ident">y</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">initial_pos</span>.<span class="ident">y</span>() <span class="op">+</span> <span class="self">self</span>.<span class="ident">fall_speed</span> <span class="op">*</span> (<span class="ident">time</span> <span class="op">-</span> <span class="self">self</span>.<span class="ident">start</span>).<span class="ident">inner_seconds</span>();
<span class="ident">Pt2D</span>::<span class="ident">new</span>(<span class="ident">x</span>, <span class="ident">y</span>)
}
} }
<span class="kw">impl</span> <span class="ident">SnowEffect</span> { <span class="kw">impl</span> <span class="ident">SnowEffect</span> {
@ -287,46 +315,48 @@
<span class="kw">let</span> <span class="ident">now</span> <span class="op">=</span> <span class="ident">Time</span>::<span class="ident">START_OF_DAY</span>; <span class="kw">let</span> <span class="ident">now</span> <span class="op">=</span> <span class="ident">Time</span>::<span class="ident">START_OF_DAY</span>;
<span class="kw">for</span> <span class="kw">_</span> <span class="kw">in</span> <span class="number">0</span>..<span class="number">60</span> { <span class="kw">for</span> <span class="kw">_</span> <span class="kw">in</span> <span class="number">0</span>..<span class="number">60</span> {
<span class="ident">snow</span>.<span class="ident">spawn_new</span>(<span class="ident">ctx</span>, <span class="ident">now</span>); <span class="kw">let</span> <span class="ident">initial_pos</span> <span class="op">=</span> <span class="ident">Pt2D</span>::<span class="ident">new</span>(
<span class="ident">snow</span>.<span class="ident">rng</span>.<span class="ident">gen_range</span>(<span class="number">0.0</span>, <span class="ident">ctx</span>.<span class="ident">canvas</span>.<span class="ident">window_width</span>),
<span class="ident">snow</span>.<span class="ident">rng</span>.<span class="ident">gen_range</span>(<span class="number">0.0</span>, <span class="ident">ctx</span>.<span class="ident">canvas</span>.<span class="ident">window_height</span>),
);
<span class="kw">let</span> <span class="ident">flake</span> <span class="op">=</span> <span class="ident">snow</span>.<span class="ident">spawn_new</span>(<span class="ident">now</span>, <span class="ident">initial_pos</span>);
<span class="ident">snow</span>.<span class="ident">flakes</span>.<span class="ident">push</span>(<span class="ident">flake</span>);
} }
<span class="ident">snow</span>.<span class="ident">event</span>(<span class="ident">ctx</span>, <span class="ident">now</span>); <span class="ident">snow</span>.<span class="ident">event</span>(<span class="ident">ctx</span>, <span class="ident">now</span>);
<span class="ident">snow</span> <span class="ident">snow</span>
} }
<span class="kw">fn</span> <span class="ident">spawn_new</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">ctx</span>: <span class="kw-2">&amp;</span><span class="ident">EventCtx</span>, <span class="ident">now</span>: <span class="ident">Time</span>) { <span class="kw">fn</span> <span class="ident">spawn_new</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">now</span>: <span class="ident">Time</span>, <span class="ident">initial_pos</span>: <span class="ident">Pt2D</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Snowflake</span> {
<span class="kw">let</span> <span class="ident">top_left</span> <span class="op">=</span> <span class="ident">Pt2D</span>::<span class="ident">new</span>( <span class="ident">Snowflake</span> {
<span class="self">self</span>.<span class="ident">rng</span>.<span class="ident">gen_range</span>(<span class="number">0.0</span>, <span class="ident">ctx</span>.<span class="ident">canvas</span>.<span class="ident">window_width</span>),
<span class="self">self</span>.<span class="ident">rng</span>.<span class="ident">gen_range</span>(<span class="number">0.0</span>, <span class="ident">ctx</span>.<span class="ident">canvas</span>.<span class="ident">window_height</span>),
);
<span class="self">self</span>.<span class="ident">flakes</span>.<span class="ident">push</span>(<span class="ident">Snowflake</span> {
<span class="ident">start</span>: <span class="ident">now</span>, <span class="ident">start</span>: <span class="ident">now</span>,
<span class="ident">top_left</span>, <span class="ident">initial_pos</span>,
}); <span class="comment">// Pixels per second</span>
<span class="comment">// TODO It&#39;d be neat to speed this up as time runs out</span>
<span class="ident">fall_speed</span>: <span class="self">self</span>.<span class="ident">rng</span>.<span class="ident">gen_range</span>(<span class="number">150.0</span>, <span class="number">300.0</span>),
<span class="ident">swoop_period</span>: <span class="self">self</span>.<span class="ident">rng</span>.<span class="ident">gen_range</span>(<span class="number">1.0</span>, <span class="number">5.0</span>),
<span class="comment">// Pixels</span>
<span class="ident">max_swoop</span>: <span class="self">self</span>.<span class="ident">rng</span>.<span class="ident">gen_range</span>(<span class="number">0.0</span>, <span class="number">50.0</span>),
}
} }
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">event</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">ctx</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="ident">now</span>: <span class="ident">Time</span>) { <span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">event</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">ctx</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">EventCtx</span>, <span class="ident">now</span>: <span class="ident">Time</span>) {
<span class="kw">let</span> <span class="ident">shape</span> <span class="op">=</span> <span class="ident">Circle</span>::<span class="ident">new</span>(<span class="ident">Pt2D</span>::<span class="ident">new</span>(<span class="number">0.0</span>, <span class="number">0.0</span>), <span class="ident">Distance</span>::<span class="ident">meters</span>(<span class="number">50.0</span>)).<span class="ident">to_polygon</span>(); <span class="kw">let</span> <span class="ident">shape</span> <span class="op">=</span> <span class="ident">Circle</span>::<span class="ident">new</span>(<span class="ident">Pt2D</span>::<span class="ident">new</span>(<span class="number">0.0</span>, <span class="number">0.0</span>), <span class="ident">Distance</span>::<span class="ident">meters</span>(<span class="number">10.0</span>)).<span class="ident">to_polygon</span>();
<span class="kw">let</span> <span class="ident">lifetime</span> <span class="op">=</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">5.0</span>);
<span class="kw">let</span> <span class="ident">lerp_scale</span> <span class="op">=</span> (<span class="number">1.0</span>, <span class="number">0.1</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</span>::<span class="ident">new</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</span>::<span class="ident">new</span>();
<span class="self">self</span>.<span class="ident">flakes</span>.<span class="ident">retain</span>(<span class="op">|</span><span class="ident">flake</span><span class="op">|</span> { <span class="kw">let</span> <span class="ident">prev_flakes</span> <span class="op">=</span> <span class="ident">std</span>::<span class="ident">mem</span>::<span class="ident">replace</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">flakes</span>, <span class="ident">Vec</span>::<span class="ident">new</span>());
<span class="kw">let</span> <span class="ident">pct</span> <span class="op">=</span> (<span class="ident">now</span> <span class="op">-</span> <span class="ident">flake</span>.<span class="ident">start</span>) <span class="op">/</span> <span class="ident">lifetime</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">new_flakes</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">new</span>();
<span class="kw">if</span> <span class="ident">pct</span> <span class="op">&gt;</span> <span class="number">1.0</span> { <span class="kw">for</span> <span class="ident">flake</span> <span class="kw">in</span> <span class="ident">prev_flakes</span> {
<span class="bool-val">false</span> <span class="kw">let</span> <span class="ident">pt</span> <span class="op">=</span> <span class="ident">flake</span>.<span class="ident">pos</span>(<span class="ident">now</span>);
<span class="kw">if</span> <span class="ident">pt</span>.<span class="ident">y</span>() <span class="op">&gt;</span> <span class="ident">ctx</span>.<span class="ident">canvas</span>.<span class="ident">window_height</span> {
<span class="kw">let</span> <span class="ident">initial_pos</span> <span class="op">=</span> <span class="ident">Pt2D</span>::<span class="ident">new</span>(<span class="self">self</span>.<span class="ident">rng</span>.<span class="ident">gen_range</span>(<span class="number">0.0</span>, <span class="ident">ctx</span>.<span class="ident">canvas</span>.<span class="ident">window_width</span>), <span class="number">0.0</span>);
<span class="ident">new_flakes</span>.<span class="ident">push</span>(<span class="self">self</span>.<span class="ident">spawn_new</span>(<span class="ident">now</span>, <span class="ident">initial_pos</span>));
} <span class="kw">else</span> { } <span class="kw">else</span> {
<span class="kw">let</span> <span class="ident">scale</span> <span class="op">=</span> <span class="ident">lerp_scale</span>.<span class="number">0</span> <span class="op">+</span> <span class="ident">pct</span> <span class="op">*</span> (<span class="ident">lerp_scale</span>.<span class="number">1</span> <span class="op">-</span> <span class="ident">lerp_scale</span>.<span class="number">0</span>); <span class="ident">batch</span>.<span class="ident">push</span>(<span class="ident">Color</span>::<span class="ident">WHITE</span>.<span class="ident">alpha</span>(<span class="number">0.5</span>), <span class="ident">shape</span>.<span class="ident">translate</span>(<span class="ident">pt</span>.<span class="ident">x</span>(), <span class="ident">pt</span>.<span class="ident">y</span>()));
<span class="ident">batch</span>.<span class="ident">push</span>( <span class="ident">new_flakes</span>.<span class="ident">push</span>(<span class="ident">flake</span>);
<span class="ident">Color</span>::<span class="ident">WHITE</span>.<span class="ident">alpha</span>(<span class="number">0.5</span>),
<span class="ident">shape</span>
.<span class="ident">scale</span>(<span class="ident">scale</span>)
.<span class="ident">translate</span>(<span class="ident">flake</span>.<span class="ident">top_left</span>.<span class="ident">x</span>(), <span class="ident">flake</span>.<span class="ident">top_left</span>.<span class="ident">y</span>()),
);
<span class="bool-val">true</span>
} }
}); }
<span class="self">self</span>.<span class="ident">flakes</span> <span class="op">=</span> <span class="ident">new_flakes</span>;
<span class="self">self</span>.<span class="ident">draw</span> <span class="op">=</span> <span class="ident">ctx</span>.<span class="ident">upload</span>(<span class="ident">batch</span>); <span class="self">self</span>.<span class="ident">draw</span> <span class="op">=</span> <span class="ident">ctx</span>.<span class="ident">upload</span>(<span class="ident">batch</span>);
} }

View File

@ -114,7 +114,7 @@
<span class="doccomment">/// The output of `rustdoc -V`</span> <span class="doccomment">/// The output of `rustdoc -V`</span>
<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">&quot;rustdoc 1.48.0 (7eac88abb 2020-11-16)&quot;</span>; <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">&quot;rustdoc 1.48.0 (7eac88abb 2020-11-16)&quot;</span>;
<span class="doccomment">/// The built-time in RFC2822, UTC</span> <span class="doccomment">/// The built-time in RFC2822, UTC</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">&quot;Sun, 06 Dec 2020 02:12:17 +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">&quot;Sun, 06 Dec 2020 02:57:19 +0000&quot;</span>;
<span class="doccomment">/// The target architecture, given by `cfg!(target_arch)`.</span> <span class="doccomment">/// The target architecture, given by `cfg!(target_arch)`.</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">&quot;x86_64&quot;</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">&quot;x86_64&quot;</span>;
<span class="doccomment">/// The endianness, given by `cfg!(target_endian)`.</span> <span class="doccomment">/// The endianness, given by `cfg!(target_endian)`.</span>