Yin and yang: Difference between revisions

Content added Content deleted
(Added solution for Action!)
Line 4,594: Line 4,594:
yin_yang 410, 90, 90
yin_yang 410, 90, 90
end</lang>
end</lang>

=={{header|Rust}}==
Creates a [http://gist.githubusercontent.com/vvshard/b11ee56adbb21967e43fb606cba19e56/raw/yin_yang.svg '''yin_yang.svg file''']. Rust version 1.58.0 or higher required

'''[dependencies]'''

svg = "0.10.0"
<lang fsharp>use svg::node::element::Path;

fn main() {
let doc = svg::Document::new()
.add(yin_yang(15.0, 1.0).set("transform", "translate(20,20)"))
.add(yin_yang(6.0, 1.0).set("transform", "translate(50,11)"));
svg::save("yin_yang.svg", &doc).unwrap();
}
/// th - the thickness of the outline around yang
fn yin_yang(r: f32, th: f32) -> Path {
let (cr, cw, ccw) = (",0,1,1,.1,0z", ",0,0,1,0,", ",0,0,0,0,");
let d = format!("M0,{0} a{0},{0}{cr} M0,{1} ", r + th, -r / 3.0) // main_circle
+ &format!("a{0},{0}{cr} m0,{r} a{0},{0}{cr} M0,0 ", r / 6.0) // eyes
+ &format!("A{0},{0}{ccw}{r} A{r},{r}{cw}-{r} A{0},{0}{cw}0", r / 2.0); // yang
Path::new().set("d", d).set("fill-rule", "evenodd")
}</lang>


=={{header|Scala}}==
=={{header|Scala}}==