This commit is contained in:
wash2 2026-04-18 20:11:25 +00:00
commit 0fa87f2b35
16382 changed files with 734838 additions and 0 deletions

View file

@ -0,0 +1,69 @@
<!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="Tools to iterate over paths."><title>cosmic::widget::canvas::path::lyon_path::iterator - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../../../../static.files/rustdoc-aa0817cf.css"><meta name="rustdoc-vars" data-root-path="../../../../../../" data-static-root-path="../../../../../../static.files/" data-current-crate="cosmic" data-themes="" data-resource-suffix="" data-rustdoc-version="1.90.0-nightly (3048886e5 2025-07-30)" data-channel="nightly" data-search-js="search-fa3e91e5.js" data-settings-js="settings-5514c975.js" ><script src="../../../../../../static.files/storage-68b7e25d.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../../../../static.files/main-eebb9057.js"></script><noscript><link rel="stylesheet" href="../../../../../../static.files/noscript-32bb7600.css"></noscript><link rel="alternate icon" type="image/png" href="../../../../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../../../../static.files/favicon-044be391.svg"></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="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../../../../cosmic/index.html">cosmic</a><span class="version">1.0.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module iterator</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#lyon-path-iterators" title="Lyon path iterators">Lyon path iterators</a><ul><li><a href="#overview" title="Overview">Overview</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In cosmic::<wbr>widget::<wbr>canvas::<wbr>path::<wbr>lyon_<wbr>path</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../../../../index.html">cosmic</a>::<wbr><a href="../../../../index.html">widget</a>::<wbr><a href="../../../index.html">canvas</a>::<wbr><a href="../../index.html">path</a>::<wbr><a href="../index.html">lyon_path</a></div><h1>Module <span>iterator</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Tools to iterate over paths.</p>
<h2 id="lyon-path-iterators"><a class="doc-anchor" href="#lyon-path-iterators">§</a>Lyon path iterators</h2><h3 id="overview"><a class="doc-anchor" href="#overview">§</a>Overview</h3>
<p>This module provides a collection of traits to extend the <code>Iterator</code> trait when
iterating over paths.</p>
<h3 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h3>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lyon_path::iterator::<span class="kw-2">*</span>;
<span class="kw">use </span>lyon_path::math::{point, vector};
<span class="kw">use </span>lyon_path::{Path, PathEvent};
<span class="comment">// Start with a path.
</span><span class="kw">let </span><span class="kw-2">mut </span>builder = Path::builder();
builder.begin(point(<span class="number">0.0</span>, <span class="number">0.0</span>));
builder.line_to(point(<span class="number">10.0</span>, <span class="number">0.0</span>));
builder.cubic_bezier_to(point(<span class="number">10.0</span>, <span class="number">10.0</span>), point(<span class="number">0.0</span>, <span class="number">10.0</span>), point(<span class="number">0.0</span>, <span class="number">5.0</span>));
builder.end(<span class="bool-val">true</span>);
<span class="kw">let </span>path = builder.build();
<span class="comment">// A simple std::iter::Iterator&lt;PathEvent&gt;,
</span><span class="kw">let </span>simple_iter = path.iter();
<span class="comment">// Make it an iterator over simpler primitives flattened events,
// which do not contain any curve. To do so we approximate each curve
// linear segments according to a tolerance threshold which controls
// the tradeoff between fidelity of the approximation and amount of
// generated events. Let's use a tolerance threshold of 0.01.
// The beauty of this approach is that the flattening happens lazily
// while iterating without allocating memory for the path.
</span><span class="kw">let </span>flattened_iter = path.iter().flattened(<span class="number">0.01</span>);
<span class="kw">for </span>evt <span class="kw">in </span>flattened_iter {
<span class="kw">match </span>evt {
PathEvent::Begin { at } =&gt; { <span class="macro">println!</span>(<span class="string">" - move to {:?}"</span>, at); }
PathEvent::Line { from, to } =&gt; { <span class="macro">println!</span>(<span class="string">" - line {:?} -&gt; {:?}"</span>, from, to); }
PathEvent::End { last, first, close } =&gt; {
<span class="kw">if </span>close {
<span class="macro">println!</span>(<span class="string">" - close {:?} -&gt; {:?}"</span>, last, first);
} <span class="kw">else </span>{
<span class="macro">println!</span>(<span class="string">" - end"</span>);
}
}
<span class="kw">_ </span>=&gt; { <span class="macro">panic!</span>() }
}
}</code></pre></div>
<p>Chaining the provided iterators allow performing some path manipulations lazily
without allocating actual path objects to hold the result of the transformations.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">extern crate </span>lyon_path;
<span class="kw">use </span>lyon_path::iterator::<span class="kw-2">*</span>;
<span class="kw">use </span>lyon_path::math::{point, Angle, Rotation};
<span class="kw">use </span>lyon_path::Path;
<span class="kw">fn </span>main() {
<span class="comment">// In practice it is more common to iterate over Path objects than vectors
// of SVG commands (the former can be constructed from the latter).
</span><span class="kw">let </span><span class="kw-2">mut </span>builder = Path::builder();
builder.begin(point(<span class="number">1.0</span>, <span class="number">1.0</span>));
builder.line_to(point(<span class="number">2.0</span>, <span class="number">1.0</span>));
builder.quadratic_bezier_to(point(<span class="number">2.0</span>, <span class="number">2.0</span>), point(<span class="number">1.0</span>, <span class="number">2.0</span>));
builder.cubic_bezier_to(point(<span class="number">0.0</span>, <span class="number">2.0</span>), point(<span class="number">0.0</span>, <span class="number">0.0</span>), point(<span class="number">1.0</span>, <span class="number">0.0</span>));
builder.end(<span class="bool-val">true</span>);
<span class="kw">let </span>path = builder.build();
<span class="kw">let </span>transform = Rotation::new(Angle::radians(<span class="number">1.0</span>));
<span class="kw">for </span>evt <span class="kw">in </span>path.iter().transformed(<span class="kw-2">&amp;</span>transform).flattened(<span class="number">0.1</span>) {
<span class="comment">// ...
</span>}
}</code></pre></div>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Flattened.html" title="struct cosmic::widget::canvas::path::lyon_path::iterator::Flattened">Flattened</a></dt><dd>An iterator that consumes <code>Event</code> iterator and yields flattened path events (with no curves).</dd><dt><a class="struct" href="struct.FromPolyline.html" title="struct cosmic::widget::canvas::path::lyon_path::iterator::FromPolyline">From<wbr>Polyline</a></dt><dd>An iterator that consumes an iterator of <code>Point</code>s and produces <code>Event</code>s.</dd><dt><a class="struct" href="struct.NoAttributes.html" title="struct cosmic::widget::canvas::path::lyon_path::iterator::NoAttributes">NoAttributes</a></dt><dt><a class="struct" href="struct.Transformed.html" title="struct cosmic::widget::canvas::path::lyon_path::iterator::Transformed">Transformed</a></dt><dd>Applies a 2D transform to a path iterator and yields the resulting path iterator.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.PathIterator.html" title="trait cosmic::widget::canvas::path::lyon_path::iterator::PathIterator">Path<wbr>Iterator</a></dt><dd>An extension trait for <code>PathEvent</code> iterators.</dd></dl></section></div></main></body></html>

View file

@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"struct":["Flattened","FromPolyline","NoAttributes","Transformed"],"trait":["PathIterator"]};

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