Pythagoras tree: Difference between revisions

m
→‎{{header|Rust}}: inserted a img
m (→‎{{header|Rust}}: inserted a img)
Line 1,959:
</syntaxhighlight>
=={{header|Rust}}==
[[File:Pythagoras tree.svg]]
Creates a [http://gist.githubusercontent.com/vvshard/833bd69acfa9160350cdbc9b57bbefe4/raw/pythagoras_tree.svg '''pythagoras_tree.svg file (12 levels)'''] that can be opened in a browser
<syntaxhighlight lang="rust">/* add to file Cargo.toml:
[dependencies]
svg = "0.10.0"
*/
 
Creates a [https://static.miraheze.org/rosettacodewiki/1/18/Pythagoras_tree.svg '''Pythagoras_tree.svg file (12 levels)''']
use svg::node::element::{Group, Polygon};
 
'''[dependencies]'''<br>
svg = "0.10.0"
<syntaxhighlight lang="rust">use svg::node::element::{Group, Polygon};
 
fn main() {
Line 1,986:
}
let (x0, y0) = (base.iter()).fold((0.0, 0.0), |(x0, y0), [(x, y), _]| (x.min(x0), y.min(y0)));
let file = "pythagoras_treePythagoras_tree.svg";
match svg::save(file, &doc.set("viewBox", (x0, y0, -x0 * 2.0, -y0))) {
Ok(_) => println!("{file} file written successfully!"),
106

edits