inital commit

This commit is contained in:
Laila van Reenen 2025-08-22 16:32:55 +02:00
commit 08096ad94c
Signed by: LailaTheElf
GPG Key ID: 8A3EF0226518C12D
5 changed files with 137 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

25
Cargo.lock generated Normal file
View File

@ -0,0 +1,25 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "birthday_colision"
version = "0.1.0"
dependencies = [
"poloto",
]
[[package]]
name = "poloto"
version = "19.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "164dbd541c9832e92fa34452e9c2e98b515a548a3f8549fb2402fe1cd5e46b96"
dependencies = [
"tagu",
]
[[package]]
name = "tagu"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eddb6b06d20fba9ed21fca3d696ee1b6e870bca0bcf9fa2971f6ae2436de576a"

7
Cargo.toml Normal file
View File

@ -0,0 +1,7 @@
[package]
name = "birthday_colision"
version = "0.1.0"
edition = "2024"
[dependencies]
poloto = "19.1.2"

77
plot.svg Normal file
View File

@ -0,0 +1,77 @@
<svg class="poloto" width="800" height="500" viewBox="0 0 800 500" xmlns="http://www.w3.org/2000/svg">
<style>
.poloto{
stroke-linecap:round;
stroke-linejoin:round;
font-family:Roboto,sans-serif;
font-size:16px;
}
.poloto_background{fill:#262626;}
.poloto_scatter{stroke-width:7}
.poloto_line{stroke-width:2}
.poloto_text{fill: white;}
.poloto_name{font-size:24px;dominant-baseline:auto;text-anchor:middle;}
.poloto_where{dominant-baseline:middle;text-anchor:start}
.poloto_text.poloto_legend{font-size:20px;dominant-baseline:middle;text-anchor:start;}
.poloto_text.poloto_ticks.poloto_y{dominant-baseline:middle;text-anchor:end}
.poloto_text.poloto_ticks.poloto_x{dominant-baseline:auto;text-anchor:middle}
.poloto_imgs.poloto_ticks{stroke: white;stroke-width:3;fill:none;stroke-dasharray:none}
.poloto_grid{stroke:gray;stroke-width:0.5}
.poloto0.poloto_stroke{stroke:blue;}
.poloto1.poloto_stroke{stroke:red;}
.poloto2.poloto_stroke{stroke:green;}
.poloto3.poloto_stroke{stroke:gold;}
.poloto4.poloto_stroke{stroke:aqua;}
.poloto5.poloto_stroke{stroke:lime;}
.poloto6.poloto_stroke{stroke:orange;}
.poloto7.poloto_stroke{stroke:chocolate;}
.poloto0.poloto_fill{fill:blue;}
.poloto1.poloto_fill{fill:red;}
.poloto2.poloto_fill{fill:green;}
.poloto3.poloto_fill{fill:gold;}
.poloto4.poloto_fill{fill:aqua;}
.poloto5.poloto_fill{fill:lime;}
.poloto6.poloto_fill{fill:orange;}
.poloto7.poloto_fill{fill:chocolate;}
</style>
<circle r="1e5" class="poloto_background" fill="white"/>
<g id="poloto_plot0" class="poloto_plot poloto_imgs poloto_line poloto0 poloto_stroke" fill="none" stroke="black">
<path d=" M 150.00 400.00 L 157.35 398.35 L 164.71 395.90 L 172.06 392.65 L 179.41 388.64 L 186.76 383.89 L 194.12 378.44 L 201.47 372.34 L 208.82 365.61 L 216.18 358.33 L 223.53 350.54 L 230.88 342.29 L 238.24 333.65 L 245.59 324.68 L 252.94 315.44 L 260.29 305.98 L 267.65 296.38 L 275.00 286.68 L 282.35 276.95 L 289.71 267.24 L 297.06 257.60 L 304.41 248.09 L 311.76 238.74 L 319.12 229.60 L 326.47 220.71 L 333.82 212.09 L 341.18 203.78 L 348.53 195.80 L 355.88 188.17 L 363.24 180.90 L 370.59 174.01 L 377.94 167.50 L 385.29 161.37 L 392.65 155.63 L 400.00 150.27 L 407.35 145.29 L 414.71 140.67 L 422.06 136.41 L 429.41 132.49 L 436.76 128.91 L 444.12 125.63 L 451.47 122.65 L 458.82 119.95 L 466.18 117.52 L 473.53 115.33 L 480.88 113.36 L 488.24 111.61 L 495.59 110.05 L 502.94 108.67 L 510.29 107.44 L 517.65 106.37 L 525.00 105.43 L 532.35 104.60 L 539.71 103.88 L 547.06 103.26 L 554.41 102.72 L 561.76 102.26 L 569.12 101.86 L 576.47 101.52 L 583.82 101.23 L 591.18 100.98 L 598.53 100.77 L 605.88 100.59 L 613.24 100.44 L 620.59 100.32 L 627.94 100.22 L 635.29 100.13 L 642.65 100.06 L 650.00 100.00"/>
</g>
<text class="poloto_text poloto_name poloto_title" x="400.00" y="37.50">birthday colision</text>
<text class="poloto_text poloto_name poloto_x" x="400.00" y="481.25">group size</text>
<text class="poloto_text poloto_name poloto_y" x="37.50" y="250.00" transform="rotate(-90,37.50,250.00)">change</text>
<text class="poloto_text poloto_ticks poloto_y">
<tspan x="135.00" y="340.61">0.2</tspan>
<tspan x="135.00" y="280.39">0.4</tspan>
<tspan x="135.00" y="220.18">0.6</tspan>
<tspan x="135.00" y="159.96">0.8</tspan>
</text>
<g class="poloto_imgs poloto_ticks poloto_y" stroke="black">
<line x1="150.00" x2="144.00" y1="340.61" y2="340.61"/>
<line x1="150.00" x2="144.00" y1="280.39" y2="280.39"/>
<line x1="150.00" x2="144.00" y1="220.18" y2="220.18"/>
<line x1="150.00" x2="144.00" y1="159.96" y2="159.96"/>
</g>
<text class="poloto_text poloto_ticks poloto_x">
<tspan x="208.82" y="430.00">10</tspan>
<tspan x="282.35" y="430.00">20</tspan>
<tspan x="355.88" y="430.00">30</tspan>
<tspan x="429.41" y="430.00">40</tspan>
<tspan x="502.94" y="430.00">50</tspan>
<tspan x="576.47" y="430.00">60</tspan>
<tspan x="650.00" y="430.00">70</tspan>
</text>
<g class="poloto_imgs poloto_ticks poloto_x" stroke="black">
<line x1="208.82" x2="208.82" y1="400.00" y2="405.00"/>
<line x1="282.35" x2="282.35" y1="400.00" y2="405.00"/>
<line x1="355.88" x2="355.88" y1="400.00" y2="405.00"/>
<line x1="429.41" x2="429.41" y1="400.00" y2="405.00"/>
<line x1="502.94" x2="502.94" y1="400.00" y2="405.00"/>
<line x1="576.47" x2="576.47" y1="400.00" y2="405.00"/>
<line x1="650.00" x2="650.00" y1="400.00" y2="405.00"/>
</g>
<path class="poloto_imgs poloto_ticks poloto_x" stroke="black" style="stroke-dasharray:7.352941176470589;stroke-dashoffset:-58.82352941176471;" d=" M 150.00 400.00 L 650.00 400.00"/>
<path class="poloto_imgs poloto_ticks poloto_y" stroke="black" style="stroke-dasharray:7.526947601925513;stroke-dashoffset:-59.39070984533007;" d=" M 150.00 400.00 L 150.00 100.00"/>
</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

27
src/main.rs Normal file
View File

@ -0,0 +1,27 @@
use poloto;
fn get_next(last: f64, step: u16) -> f64 {
let c: f64 = f64::from(step - 1) / 365f64;
c * (1.0-last) + last
}
fn main() {
let mut i: u16 = 2;
let mut chance: f64 = 0.0;
let mut chances: Vec<[f64; 2]> = Vec::new();
while i <= 70 {
chance = get_next(chance, i);
chances.push([f64::from(i), chance]);
println!("{}: {}", i, chance);
i += 1;
}
let plot = poloto::build::plot("").line(chances);
let file = std::fs::File::create("./plot.svg").unwrap();
let _ = poloto::frame_build()
.data(plot)
.build_and_label(("birthday colision", "group size", "change"))
.append_to(poloto::header().dark_theme())
.render_io_write(file);
}