Commit 965ea9c
## Summary
- **`grid_color(Color32)`** — sets the base color for grid lines
independently of `text_color()`, while preserving the strength-based
fading.
- **`grid_fade(f32)`** — controls the contrast between dense and sparse
grid lines. `0.0` = uniform (all lines same opacity), `0.5` = default
(sqrt), `1.0` = maximum fade. The zoom-based density logic is always
preserved.
## Motivation
When embedding `egui_plot` in an application with its own design system,
the grid color needs to be independent of text color. The current
behavior derives grid color from `ui.visuals().text_color()`, which
couples grid styling to text styling.
Similarly, the strength curve (hardcoded `sqrt`) may not suit all visual
designs — some applications want less contrast between grid levels, or
uniform grid lines.
## Changes
Single file change in `plot.rs`:
- Added `grid_color: Option<Color32>` field with `.grid_color()` builder
method
- Added `grid_strength_exponent: f32` field (default `0.5`) with
`.grid_fade()` builder method
- `paint_grid_direction` uses the custom base color and exponent when
set, falls back to existing behavior otherwise
---------
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
1 parent c7feb89 commit 965ea9c
1 file changed
Lines changed: 33 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
| |||
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| 185 | + | |
| 186 | + | |
183 | 187 | | |
184 | 188 | | |
185 | 189 | | |
| |||
628 | 632 | | |
629 | 633 | | |
630 | 634 | | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
631 | 662 | | |
632 | 663 | | |
633 | 664 | | |
| |||
1487 | 1518 | | |
1488 | 1519 | | |
1489 | 1520 | | |
1490 | | - | |
| 1521 | + | |
| 1522 | + | |
1491 | 1523 | | |
1492 | 1524 | | |
1493 | 1525 | | |
| |||
0 commit comments