gdritter repos axidraw-experiments / 04f6508
Some little experiments Getty Ritter 5 years ago
5 changed file(s) with 213 addition(s) and 0 deletion(s). Collapse all Expand all
1 /target
2 **/*.rs.bk
3 *~
1 [[package]]
2 name = "axidraw-experiments"
3 version = "0.1.0"
4 dependencies = [
5 "gunpowder_treason 0.1.0",
6 "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
7 "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
8 ]
9
10 [[package]]
11 name = "bitflags"
12 version = "1.0.3"
13 source = "registry+https://github.com/rust-lang/crates.io-index"
14
15 [[package]]
16 name = "cloudabi"
17 version = "0.0.3"
18 source = "registry+https://github.com/rust-lang/crates.io-index"
19 dependencies = [
20 "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
21 ]
22
23 [[package]]
24 name = "either"
25 version = "1.5.0"
26 source = "registry+https://github.com/rust-lang/crates.io-index"
27
28 [[package]]
29 name = "fuchsia-zircon"
30 version = "0.3.3"
31 source = "registry+https://github.com/rust-lang/crates.io-index"
32 dependencies = [
33 "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
34 "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
35 ]
36
37 [[package]]
38 name = "fuchsia-zircon-sys"
39 version = "0.3.3"
40 source = "registry+https://github.com/rust-lang/crates.io-index"
41
42 [[package]]
43 name = "gunpowder_treason"
44 version = "0.1.0"
45
46 [[package]]
47 name = "itertools"
48 version = "0.7.8"
49 source = "registry+https://github.com/rust-lang/crates.io-index"
50 dependencies = [
51 "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
52 ]
53
54 [[package]]
55 name = "libc"
56 version = "0.2.43"
57 source = "registry+https://github.com/rust-lang/crates.io-index"
58
59 [[package]]
60 name = "rand"
61 version = "0.5.5"
62 source = "registry+https://github.com/rust-lang/crates.io-index"
63 dependencies = [
64 "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
65 "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
66 "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
67 "rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
68 "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
69 ]
70
71 [[package]]
72 name = "rand_core"
73 version = "0.2.1"
74 source = "registry+https://github.com/rust-lang/crates.io-index"
75
76 [[package]]
77 name = "winapi"
78 version = "0.3.5"
79 source = "registry+https://github.com/rust-lang/crates.io-index"
80 dependencies = [
81 "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
82 "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
83 ]
84
85 [[package]]
86 name = "winapi-i686-pc-windows-gnu"
87 version = "0.4.0"
88 source = "registry+https://github.com/rust-lang/crates.io-index"
89
90 [[package]]
91 name = "winapi-x86_64-pc-windows-gnu"
92 version = "0.4.0"
93 source = "registry+https://github.com/rust-lang/crates.io-index"
94
95 [metadata]
96 "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789"
97 "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
98 "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
99 "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
100 "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
101 "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
102 "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
103 "checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
104 "checksum rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edecf0f94da5551fc9b492093e30b041a891657db7940ee221f9d2f66e82eef2"
105 "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd"
106 "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
107 "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1 [package]
2 name = "axidraw-experiments"
3 version = "0.1.0"
4 authors = ["Getty Ritter <gettylefou@gmail.com>"]
5
6 [dependencies]
7 gunpowder_treason = { path = "../gunpowder_treason" }
8 rand = "*"
9 itertools = "*"
10
11 [[bin]]
12 name = "circles"
13 path = "src/circles.rs"
14
15 [[bin]]
16 name = "hexes"
17 path = "src/hexes.rs"
1 extern crate gunpowder_treason as gt;
2 #[macro_use] extern crate itertools;
3 extern crate rand;
4
5 fn main() {
6 let mut drawing = gt::svg(8.5, 11.0);
7
8 for y in 1..=10 {
9 drawing.add(gt::line(0.75, y as f64)
10 .to(8.5 - 0.75, y as f64));
11 }
12 for x in 0..=7 {
13 drawing.add(gt::line(0.75 + x as f64, 1.0)
14 .to(0.75 + x as f64, 10.0));
15 }
16 for (x, y) in iproduct!(0..7, 1..10) {
17 for _ in 0..(rand::random::<u32>() % 4) + 1 {
18 drawing.add(gt::circle(
19 (1.25 + x as f64, 0.5 + y as f64),
20 0.2 * rand::random::<f64>(),
21 ));
22 }
23 }
24 drawing.to_stdout();
25 }
1 extern crate gunpowder_treason as gt;
2 #[macro_use] extern crate itertools;
3
4 use std::f64::consts::PI;
5
6 fn main() {
7 let mut drawing = gt::svg(11.0, 14.0);
8 drawing.add(gt::rect((0.0, 0.0), (11.0, 14.0)));
9 const N: f64 = 0.2;
10 const THETA: f64 = PI / 3.0;
11 const COLS: u32 = 16;
12 const ROWS: u32 = 36;
13
14 const XO: f64 = 0.8;
15 const YO: f64 = 0.8;
16
17 for (y, x) in iproduct!(0..ROWS, 0..COLS) {
18 let d = 2.0 * (N + THETA.cos() * N);
19 let a = THETA.cos() * N;
20 let h = THETA.sin() * N;
21 let h2 = THETA.sin() * N * 2.0;
22
23 let by = YO + y as f64 * h2;
24
25 drawing.add(
26 gt::line(XO + d * x as f64, by)
27 .to(XO + d * x as f64 - a, by + h)
28 );
29 drawing.add(
30 gt::line(XO + d * x as f64, by)
31 .to(XO + d * x as f64 + N, by)
32 );
33 drawing.add(
34 gt::line(XO + d * x as f64 + N, by)
35 .to(XO + d * x as f64 + N + a, by + h)
36 );
37 if x < COLS - 1 {
38 drawing.add(
39 gt::line(XO + d * x as f64 + N + a, by + h)
40 .to(XO + d * x as f64 + N * 2.0 + a, by + h)
41 );
42 }
43
44 drawing.add(
45 gt::line(XO + d * x as f64 - a, by + h)
46 .to(XO + d * x as f64, by + h * 2.0)
47 );
48 if y == ROWS - 1 {
49 drawing.add(
50 gt::line(XO + d * x as f64, by + h * 2.0)
51 .to(XO + d * x as f64 + N, by + h * 2.0)
52 );
53 }
54 drawing.add(
55 gt::line(XO + d * x as f64 + N + a, by + h)
56 .to(XO + d * x as f64 + N, by + h * 2.0)
57 );
58
59 }
60 drawing.to_stdout();
61 }