circles.rs 742 B

12345678910111213141516171819202122232425262728
  1. extern crate gunpowder_treason as gt;
  2. #[macro_use] extern crate itertools;
  3. extern crate rand;
  4. fn main() {
  5. let mut drawing = gt::svg(8.5, 11.0);
  6. for y in 1..11 {
  7. drawing.add(gt::line(0.75, y as f64)
  8. .to(8.5 - 0.75, y as f64));
  9. }
  10. for x in 0..8 {
  11. drawing.add(gt::line(0.75 + x as f64, 1.0)
  12. .to(0.75 + x as f64, 10.0));
  13. }
  14. for (x, y) in iproduct!(0..7, 1..10) {
  15. for _ in 0..(rand::random::<u32>() % 4) + 1 {
  16. drawing.add(gt::circle(
  17. (1.25 + x as f64, 0.5 + y as f64),
  18. 0.2 * rand::random::<f64>(),
  19. ));
  20. }
  21. }
  22. if let Err(e) = drawing.output("circles") {
  23. eprintln!("{}", e);
  24. }
  25. }