Sierpinski pentagon: Difference between revisions
m
Output is vertically centred, use polygon instead of path
m (Output is vertically centred, use polygon instead of path) |
m (Output is vertically centred, use polygon instead of path) |
||
Line 1,141:
fn sierpinski_pentagon(mut document : svg::Document, mut x : f64, mut y : f64,
mut side : f64, order: usize) -> svg::Document {
use svg::node::element::
use std::f64::consts::PI;
Line 1,150 ⟶ 1,149:
if order == 1 {
let mut
for _ in 0..5 {
x += angle.cos() * side;
y -= angle.sin() * side;
angle += degrees72;
}
.set("fill", "blue")
.set("stroke", "black")
.set("stroke-width", "1")
.set("
document = document.add(
} else {
side *= scale_factor;
Line 1,186 ⟶ 1,184:
let radius = (size as f64)/2.0 - 2.0 * margin;
let side = radius * (0.2 * PI).sin() * 2.0;
let height = side * ((0.2 * PI).sin() + (0.4 * PI).sin());
let x = (size as f64)/2.0;
let y =
let rect = Rectangle::new()
|