Commit 5902eb9
## 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 c008e48 commit 5902eb9
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 | | |
| |||
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
| 187 | + | |
| 188 | + | |
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
| |||
637 | 641 | | |
638 | 642 | | |
639 | 643 | | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
640 | 671 | | |
641 | 672 | | |
642 | 673 | | |
| |||
1496 | 1527 | | |
1497 | 1528 | | |
1498 | 1529 | | |
1499 | | - | |
| 1530 | + | |
| 1531 | + | |
1500 | 1532 | | |
1501 | 1533 | | |
1502 | 1534 | | |
| |||
0 commit comments