Skip to content

Add grid_color and grid_fade API#235

Open
gavrelina wants to merge 1 commit intoemilk:mainfrom
gavrelina:katya/grid-color-api
Open

Add grid_color and grid_fade API#235
gavrelina wants to merge 1 commit intoemilk:mainfrom
gavrelina:katya/grid-color-api

Conversation

@gavrelina
Copy link

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

@github-actions
Copy link

View snapshot changes at kitdiff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant