Debian Codegraph @

examples/rainbow.rs

raw symbols SCIP
1 #[cfg(feature = "color")]
2 use coloredrust-analyzer cargo colored 3.1.1 crate/::Colorrust-analyzer cargo colored 3.1.1 color/Color#;
3 #[cfg(feature = "color")]
4 use rasciigraphrust-analyzer cargo rasciigraph 0.3.0 crate/::{plot_many_coloredrust-analyzer cargo rasciigraph 0.3.0 plot_many_colored()., Configrust-analyzer cargo rasciigraph 0.3.0 Config#};
5
6 #[cfg(feature = "color")]
7 fn mainrust-analyzer cargo rasciigraph 0.3.0 main().() {
8 // Generate concentric semi-circles
9 let mut data = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; 6];
10 for i in 0i64..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6 {
11 for x in -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().40i64..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#40 {
12 let v = if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]ge().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().(40 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().i) && x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]le().(40 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().i) {
13 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(((40 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().i) as f64).powirust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]powi().(2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().(x as f64).powirust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]powi().(2))
14 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| v.sqrtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]sqrt().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().2.0)
15 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(f64::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]NAN.)
16 } else {
17 f64::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]NAN.
18 };
19 data[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().i as usize]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut()..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(v);
20 }
21 }
22
23 // Define the configuration
24 let config = Configrust-analyzer cargo rasciigraph 0.3.0 Config#::defaultrust-analyzer cargo rasciigraph 0.3.0 impl#[Config][Default]default().()
25 .with_heightrust-analyzer cargo rasciigraph 0.3.0 impl#[Config]with_height().(20)
26 .with_widthrust-analyzer cargo rasciigraph 0.3.0 impl#[Config]with_width().(80)
27 .with_captionrust-analyzer cargo rasciigraph 0.3.0 impl#[Config]with_caption().("Concentric Semi-Circles".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
28 .with_caption_colorrust-analyzer cargo rasciigraph 0.3.0 impl#[Config]with_caption_color().(Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#)
29 .with_axis_colorrust-analyzer cargo rasciigraph 0.3.0 impl#[Config]with_axis_color().(Colorrust-analyzer cargo colored 3.1.1 color/Color#::Greenrust-analyzer cargo colored 3.1.1 color/Color#Green#)
30 .with_series_legendsrust-analyzer cargo rasciigraph 0.3.0 impl#[Config]with_series_legends().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["gemini".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "chatgpt".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()])
31 .with_series_colorsrust-analyzer cargo rasciigraph 0.3.0 impl#[Config]with_series_colors().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
32 Colorrust-analyzer cargo colored 3.1.1 color/Color#::Redrust-analyzer cargo colored 3.1.1 color/Color#Red#,
33 Colorrust-analyzer cargo colored 3.1.1 color/Color#::Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow#,
34 Colorrust-analyzer cargo colored 3.1.1 color/Color#::Greenrust-analyzer cargo colored 3.1.1 color/Color#Green#,
35 Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#,
36 Colorrust-analyzer cargo colored 3.1.1 color/Color#::Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta#,
37 Colorrust-analyzer cargo colored 3.1.1 color/Color#::Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan#,
38 ]);
39
40 // Generate the plot
41 let result = plot_many_coloredrust-analyzer cargo rasciigraph 0.3.0 plot_many_colored().(data, config);
42
43 // Print the result
44 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", result);
45 }