Skip to content

Commit

Permalink
Reformat using rustfmt, new style.
Browse files Browse the repository at this point in the history
  • Loading branch information
SiegeLordEx authored and SiegeLord committed Jun 15, 2017
1 parent ad5ad17 commit 8ae8cdd
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 199 deletions.
4 changes: 1 addition & 3 deletions examples/animation_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ fn main()
loop
{
fg.clear_axes();
fg.axes2d()
.set_y_range(Fix(-1.0), Fix(1.0))
.lines(x.iter(), x.iter().map(|&x| (x + t).sin()), &[]);
fg.axes2d().set_y_range(Fix(-1.0), Fix(1.0)).lines(x.iter(), x.iter().map(|&x| (x + t).sin()), &[]);
t += 0.1;
fg.show();
sleep(Duration::from_millis(500));
Expand Down
2 changes: 1 addition & 1 deletion examples/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

extern crate argparse_rs;

use gnuplot::*;
use self::argparse_rs::*;
use gnuplot::*;
use std::env;

#[derive(Copy, Clone)]
Expand Down
55 changes: 32 additions & 23 deletions examples/example1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ fn example(c: Common)
let x = &[1.0f32, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0];
let x = x.iter2();
let y1: Vec<f32> = x.map(|&v| {
let z = v - 4.0;
z * z - 5.0
})
.collect();
let z = v - 4.0;
z * z - 5.0
}).collect();
let y1 = y1.iter2();
let y2: Vec<f32> = x.map(|&v| {
let z = v - 4.0;
-z * z + 5.0
})
.collect();
let z = v - 4.0;
-z * z + 5.0
}).collect();
let y2 = y2.iter2();
let y3: Vec<f32> = x.map(|&v| v - 4.0).collect();
let y3 = y3.iter2();
Expand All @@ -41,11 +39,13 @@ fn example(c: Common)
.set_border(true, &[Left, Bottom], &[LineWidth(2.0)])
.set_x_label("Abscissa", &[])
.set_y_label("Ordinate", &[])
.arrow(Axis(5.7912),
Axis(2.7912),
Axis(5.7912),
Axis(1.7912),
&[ArrowType(Closed), ArrowSize(0.1), LineWidth(2.0), Color("black")])
.arrow(
Axis(5.7912),
Axis(2.7912),
Axis(5.7912),
Axis(1.7912),
&[ArrowType(Closed), ArrowSize(0.1), LineWidth(2.0), Color("black")],
)
.label("Here", Axis(5.7912), Axis(3.1), &[TextAlign(AlignCenter)])
.fill_between(x, y1.map(|&y| y * 0.85 - 1.0), y1.map(|&y| y * 1.15 + 1.0), &[Color("#aaaaff")])
.lines(x, y1, &[Caption("(x - 4)^2 - 5"), LineWidth(1.5), Color("black")])
Expand Down Expand Up @@ -80,8 +80,7 @@ fn example(c: Common)
let mut fg = Figure::new();
c.set_term(&mut fg);

fg.axes2d()
.lines(x, y1, &[Caption("Lines"), LineWidth(3.0), Color("violet")]);
fg.axes2d().lines(x, y1, &[Caption("Lines"), LineWidth(3.0), Color("violet")]);

fg.axes2d()
.set_pos(0.2, 0.4)
Expand Down Expand Up @@ -126,10 +125,12 @@ fn example(c: Common)
.lines(x, y2, &[Color("black"), LineWidth(2.0), Caption("C")])
.lines(x, y3, &[Color("black"), LineWidth(2.0), LineStyle(DotDotDash), Caption("B")])
.set_title("Fill and legend fg1.6", &[])
.set_legend(Graph(0.5),
Graph(-0.2),
&[Horizontal, Placement(AlignCenter, AlignTop), Title("Legend Title")],
&[TextAlign(AlignRight)]);
.set_legend(
Graph(0.5),
Graph(-0.2),
&[Horizontal, Placement(AlignCenter, AlignTop), Title("Legend Title")],
&[TextAlign(AlignRight)],
);

c.show(&mut fg, "fg1.6.gnuplot");

Expand All @@ -145,10 +146,18 @@ fn example(c: Common)
.set_x_label("X Label", &[Font("Arial", 24.0), TextColor("red"), Rotate(45.0)])
.set_y_label("Y Label", &[Rotate(0.0)])
.set_title("Goings nuts with the formatting fg1.7", &[Font("Times", 24.0), TextOffset(-10.0, 0.5)])
.label("Intersection",
Axis(2.208),
Axis(-1.791),
&[MarkerSymbol('*'), TextAlign(AlignCenter), TextOffset(0.0, -1.0), MarkerColor("red"), MarkerSize(2.0)]);
.label(
"Intersection",
Axis(2.208),
Axis(-1.791),
&[
MarkerSymbol('*'),
TextAlign(AlignCenter),
TextOffset(0.0, -1.0),
MarkerColor("red"),
MarkerSize(2.0),
],
);

c.show(&mut fg, "fg1.7.gnuplot");
}
Expand Down
38 changes: 23 additions & 15 deletions examples/example2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ fn example(c: Common)
fg.axes2d()
.set_title("Arrows fg2.1", &[])
.lines(x, y1, &[LineWidth(3.0), Color("brown"), LineStyle(DotDash)])
.arrow(Graph(0.5),
Graph(1.0),
Axis(1.0),
Axis(1.0),
&[ArrowType(Filled), ArrowSize(0.1), LineStyle(DotDotDash), LineWidth(2.0), Color("red")])
.arrow(
Graph(0.5),
Graph(1.0),
Axis(1.0),
Axis(1.0),
&[ArrowType(Filled), ArrowSize(0.1), LineStyle(DotDotDash), LineWidth(2.0), Color("red")],
)
.arrow(Graph(0.5), Graph(1.0), Axis(3.0), Axis(9.0), &[ArrowType(Open), Color("green")]);

c.show(&mut fg, "fg2.1.gnuplot");
Expand All @@ -70,13 +72,15 @@ fn example(c: Common)
fg.axes2d()
.set_title("Axis Ticks fg2.3", &[])
.lines(x3, y3, &[LineWidth(2.0), Color("blue")])
.set_x_ticks_custom((0..5)
.map(|i| 2 * i)
.map(|x| Major(x as f32, Fix("%.2f ms".to_string())))
.chain((0..5).map(|i| 2 * i + 1).map(|x| Minor(x as f32)))
.chain(Some(Major(-2.1f32, Fix("%.2f ms".to_string()))).into_iter()),
&[MajorScale(2.0), MinorScale(0.5), OnAxis(true)],
&[TextColor("blue"), TextAlign(AlignCenter)])
.set_x_ticks_custom(
(0..5)
.map(|i| 2 * i)
.map(|x| Major(x as f32, Fix("%.2f ms".to_string())))
.chain((0..5).map(|i| 2 * i + 1).map(|x| Minor(x as f32)))
.chain(Some(Major(-2.1f32, Fix("%.2f ms".to_string()))).into_iter()),
&[MajorScale(2.0), MinorScale(0.5), OnAxis(true)],
&[TextColor("blue"), TextAlign(AlignCenter)],
)
.set_y_ticks(Some((Fix(2.0), 1)), &[Mirror(false), Format("%.1f s")], &[]);

c.show(&mut fg, "fg2.3.gnuplot");
Expand All @@ -98,9 +102,13 @@ fn example(c: Common)
let mut fg = Figure::new();
c.set_term(&mut fg);

fg.axes2d()
.set_title("Image fg2.5", &[])
.image(z1.iter(), zw, zh, Some((-4.0, -4.0, 4.0, 4.0)), &[]);
fg.axes2d().set_title("Image fg2.5", &[]).image(
z1.iter(),
zw,
zh,
Some((-4.0, -4.0, 4.0, 4.0)),
&[],
);

c.show(&mut fg, "fg2.5.gnuplot");

Expand Down
14 changes: 8 additions & 6 deletions examples/example4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ fn example(c: Common)

c.show(&mut fg, "fg4.5.gnuplot");

let palette: [(f32, f32, f32, f32); 6] = [(0.00, 1.0, 0.0, 0.0),
(0.33, 1.0, 0.0, 0.0),
(0.33, 0.0, 1.0, 0.0),
(0.66, 0.0, 1.0, 0.0),
(0.66, 0.0, 0.0, 1.0),
(1.00, 0.0, 0.0, 1.0)];
let palette: [(f32, f32, f32, f32); 6] = [
(0.00, 1.0, 0.0, 0.0),
(0.33, 1.0, 0.0, 0.0),
(0.33, 0.0, 1.0, 0.0),
(0.66, 0.0, 1.0, 0.0),
(0.66, 0.0, 0.0, 1.0),
(1.00, 0.0, 0.0, 1.0),
];

let mut fg = Figure::new();
c.set_term(&mut fg);
Expand Down
6 changes: 5 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ fn_args_density = "Compressed"
use_try_shorthand = true
ideal_width = 120
max_width = 140
struct_lit_width = 35
struct_variant_width = 100
array_width = 100
struct_lit_width = 100
fn_call_width = 100
chain_one_line_max = 100
single_line_if_else_max_width = 0
write_mode = "Overwrite"
Loading

0 comments on commit 8ae8cdd

Please sign in to comment.