Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/controls_toggles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl App {
[x, (x * 0.8).sin()]
})
.collect(),
LineStyle::Solid,
LineStyle::solid(),
)
.with_label("sin(x)")
.with_color(Color::from_rgb(0.3, 0.7, 1.0));
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_ticks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn new() -> PlotWidget {
})
.collect();

let series = Series::new(positions, MarkerStyle::circle(5.0), LineStyle::Solid)
let series = Series::new(positions, MarkerStyle::circle(5.0), LineStyle::solid())
.with_label("Temperature")
.with_point_colors(colors)
.with_color(Color::from_rgb(1.0, 0.5, 0.2));
Expand Down
6 changes: 3 additions & 3 deletions examples/fills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ fn new() -> PlotWidget {
.collect();

// Create a bunch of series and lines.
let upper_series = Series::line_only(upper_positions, LineStyle::Solid)
let upper_series = Series::line_only(upper_positions, LineStyle::solid())
.with_marker_style(MarkerStyle::circle(3.5))
.with_color(Color::from_rgb(0.15, 0.55, 0.95))
.with_label("upper series");
let lower_series = Series::line_only(lower_positions, LineStyle::Dashed { length: 8.0 })
let lower_series = Series::line_only(lower_positions, LineStyle::dashed(8.0))
.with_marker_style(MarkerStyle::ring(3.0))
.with_color(Color::from_rgb(0.95, 0.45, 0.15))
.with_label("lower series (sparse)");
let baseline = HLine::new(0.0)
.with_label("y = 0")
.with_style(LineStyle::Dotted { spacing: 4.0 })
.with_style(LineStyle::dotted(4.0))
.with_color(Color::from_rgb(0.7, 0.7, 0.7));
let hband_low = HLine::new(1.9)
.with_label("h-band low")
Expand Down
10 changes: 3 additions & 7 deletions examples/high_precision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ fn new() -> PlotWidget {
})
.with_cursor_provider(|x, y| format!("Cursor:\nt = {:.9} s\nvalue = {:.6}", x, y))
.add_series(
Series::new(
positions,
MarkerStyle::square(4.0),
LineStyle::Dashed { length: 10.0 },
)
.with_label("both_markers_and_lines")
.with_color(Color::from_rgb(0.3, 0.9, 0.3)),
Series::new(positions, MarkerStyle::square(4.0), LineStyle::dashed(10.0))
.with_label("both_markers_and_lines")
.with_color(Color::from_rgb(0.3, 0.9, 0.3)),
)
.with_cursor_overlay(true)
.with_crosshairs(true)
Expand Down
9 changes: 4 additions & 5 deletions examples/interactive_spline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ impl App {
[4.0, 0.2],
];

let control_poly =
Series::line_only(control_points.clone(), LineStyle::Dashed { length: 8.0 })
.with_label("control polygon")
.with_color(Color::from_rgb(0.5, 0.5, 0.5));
let control_poly = Series::line_only(control_points.clone(), LineStyle::dashed(8.0))
.with_label("control polygon")
.with_color(Color::from_rgb(0.5, 0.5, 0.5));

let control_series = Series::markers_only(control_points.clone(), MarkerStyle::circle(7.0))
.with_label("control points")
.with_color(Color::from_rgb(1.0, 0.5, 0.2));

let spline = Series::line_only(sample_catmull_rom(&control_points, 28), LineStyle::Solid)
let spline = Series::line_only(sample_catmull_rom(&control_points, 28), LineStyle::solid())
.with_label("catmull-rom spline")
.with_color(Color::from_rgb(0.2, 0.8, 1.0));

Expand Down
12 changes: 4 additions & 8 deletions examples/line_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn new() -> PlotWidget {
})
.collect();

let s1 = Series::line_only(positions, LineStyle::Solid)
let s1 = Series::line_only(positions, LineStyle::solid().with_pixel_width(4.0))
.with_label("sine_line_only")
.with_color(Color::from_rgb(0.3, 0.3, 0.9));

Expand All @@ -80,13 +80,9 @@ fn new() -> PlotWidget {
[x, y]
})
.collect();
let s3 = Series::new(
positions,
MarkerStyle::square(4.0),
LineStyle::Dashed { length: 10.0 },
)
.with_label("both_markers_and_lines")
.with_color(Color::from_rgb(0.3, 0.9, 0.3));
let s3 = Series::new(positions, MarkerStyle::square(4.0), LineStyle::dashed(10.0))
.with_label("both_markers_and_lines")
.with_color(Color::from_rgb(0.3, 0.9, 0.3));

PlotWidgetBuilder::new()
.with_hover_highlight_provider(|context, point| {
Expand Down
12 changes: 6 additions & 6 deletions examples/reference_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn new() -> PlotWidget {
.with_label("tan_1")
.with_color(Color::from_rgb(0.3, 0.6, 0.9));

let tan2 = Series::line_only(tan_seg2, LineStyle::Solid)
let tan2 = Series::line_only(tan_seg2, LineStyle::solid())
.with_marker_style(MarkerStyle::star(10.0))
.with_color(Color::from_rgb(0.7, 0.2, 0.1))
.with_label("tan_2");
Expand All @@ -59,7 +59,7 @@ fn new() -> PlotWidget {
tanh_positions.push([x, (k * (x - 1.5 * PI)).tanh()]);
x += 0.01;
}
let tanh_s = Series::line_only(tanh_positions, LineStyle::Dashed { length: 8.0 })
let tanh_s = Series::line_only(tanh_positions, LineStyle::dashed(8.0))
.with_label("y = tanh(1.2·(x - 1.5π))")
.with_color(Color::from_rgb(0.2, 0.8, 0.5));

Expand All @@ -68,26 +68,26 @@ fn new() -> PlotWidget {
.with_label("π")
.with_color(Color::from_rgb(0.9, 0.3, 0.3))
.with_width(2.0)
.with_style(LineStyle::Solid);
.with_style(LineStyle::solid());

let vline2 = VLine::new(TAU)
.with_label("2π")
.with_color(Color::from_rgb(0.9, 0.5, 0.3))
.with_width(2.0)
.with_style(LineStyle::Dashed { length: 1.0 });
.with_style(LineStyle::dashed(1.0));

// Add horizontal reference lines at y = ±1 (asymptotes of tanh)
let hline1 = HLine::new(1.0)
.with_label("y=1.0")
.with_color(Color::from_rgb(0.3, 0.9, 0.5))
.with_width(2.5)
.with_style(LineStyle::Dotted { spacing: 5.0 });
.with_style(LineStyle::dotted(5.0));

let hline2 = HLine::new(-1.0)
.with_label("y=-1.0")
.with_color(Color::from_rgb(0.3, 0.9, 0.5))
.with_width(2.5)
.with_style(LineStyle::Dotted { spacing: 5.0 });
.with_style(LineStyle::dotted(5.0));

PlotWidgetBuilder::new()
.with_x_label("x")
Expand Down
12 changes: 4 additions & 8 deletions examples/three_plots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl App {
[x, y]
})
.collect();
let s1 = Series::line_only(positions, LineStyle::Solid).with_label("sine_line_only");
let s1 = Series::line_only(positions, LineStyle::solid()).with_label("sine_line_only");
let s1_id = s1.id;
let w1 = PlotWidgetBuilder::new()
.disable_scroll_to_pan()
Expand Down Expand Up @@ -200,13 +200,9 @@ impl App {
[x, y]
})
.collect();
let s3 = Series::new(
positions,
MarkerStyle::square(4.0),
LineStyle::Dashed { length: 10.0 },
)
.with_label("both_markers_and_lines")
.with_color([0.3, 0.9, 0.3]);
let s3 = Series::new(positions, MarkerStyle::square(4.0), LineStyle::dashed(10.0))
.with_label("both_markers_and_lines")
.with_color([0.3, 0.9, 0.3]);
let s3_id = s3.id;
let w3 = PlotWidgetBuilder::new()
.disable_scroll_to_pan()
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub use plot_widget::{HighlightPoint, PlotWidget};
pub use plot_widget_builder::PlotWidgetBuilder;
pub use point::{MarkerType, Point};
pub use reference_lines::{HLine, VLine};
pub use series::{LineStyle, MarkerSize, MarkerStyle, Series, ShapeId};
pub use series::{LineStyle, LineType, MarkerStyle, Series, ShapeId, Size};
pub use ticks::{
Tick, TickFormatter, TickProducer, default_formatter, default_tick_producer, log_formatter,
log_tick_producer,
Expand Down
4 changes: 2 additions & 2 deletions src/picking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use glam::{DVec2, Vec2};
use iced::Rectangle;
use iced::wgpu::*;

use crate::{MarkerSize, Point, PointId, camera::Camera, plot_state::SeriesSpan};
use crate::{Point, PointId, Size, camera::Camera, plot_state::SeriesSpan};

/// Threshold for number of points above which GPU picking is used instead of CPU picking.
pub(crate) const CPU_PICK_THRESHOLD: usize = 5000;
Expand Down Expand Up @@ -217,7 +217,7 @@ fn cpu_pick_hit(
let dx = screen_x - cursor_x;
let dy = screen_y - cursor_y;
let d2 = dx * dx + dy * dy;
let marker_px = MarkerSize::marker_size_px(pt.size, pt.size_mode, camera, bounds) as f64;
let marker_px = Size::size_px(pt.size, pt.size_mode, camera, bounds) as f64;
let radius = hover_radius_px as f64 + marker_px * 0.5;
if d2 <= radius * radius {
if let Some((_, best_d2)) = best {
Expand Down
Loading