Interactive 2D wave optics simulator. Turn any image into a refractive scene, add sources, watch waves refract, diffract and interfere. Probes, intensity maps, video export.
C#
Scheme editor: "Reduce to 9 stops" goes, a copy is a copy, a loaded table keeps its bends
Alexander Graefd3bf50f2f617
diff --git a/CLAUDE.md b/CLAUDE.mdindex 055598a..6ebd7d7 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -175,13 +175,12 @@ WPF shell as it stands:then the built-ins.`Controls/ColorSchemePicker` (a `ComboBox`, value = the scheme name) lists the project's schemestagged "project", then the shared ones of the layer's `Kind`, each with a gradient strip, plus- "Load from file…" (JSON or `.wdscheme` into the project) and "Edit a copy in the project…" (clone,- reduced to 9 stops, selected in the tree). The tree has a "Colour schemes" folder (add, duplicate,+ "Load from file…" (JSON or `.wdscheme` into the project) and "Edit a copy in the project…" (clone, selected in the tree). The tree has a "Colour schemes" folder (add, duplicate,remove, move, drag like sources); `Views/ColorSchemeView` edits name, kind (the author's "category", afree text his program stored but never read, was dropped 2026-10-15 from the model, the editor, the tablesand the files; an old file's attribute is ignored on load, the JSON export no longer writes it) and one rowper stop (position as a number box, swatch, hex), with "Add stop" (into the widest gap) and a- remove button per row, plus "Reduce to 9 stops" for a 255-stop table, and a "Based on" combo that+ remove button per row, and a "Based on" combo thatcopies any shared or project scheme's stops into the one being edited (a new scheme starts grey).Editsrecolour the preview at once (`ProjectWatcher` reports them as display changes,@@ -202,7 +201,7 @@ WPF shell as it stands:scheme takes its layers along** (2026-10-15): `Project` watches its scheme list and each scheme's `Name`, keepsthe last known name per scheme, and on a rename sets every display layer that named the old name(case-insensitively) to the new one; in the model, so every editor and the importer get it, and a removed scheme- is let go. The preview keeps its colours through a rename (the harness proves it by the field picture's hash). **The colour picker** (2026-10-15, the user's choice of an+ is let go. The preview keeps its colours through a rename (the harness proves it by the field picture's hash). **No reduction in the editor** (2026-10-15, the user's call): the "Reduce to 9 stops" button, its command and strings and `ColorScheme.ReduceToStops` are gone, since the author's nine-stop form means nothing here (stops sit anywhere) and every shipped scheme is slimmed already; "Edit a copy in the project…" clones a scheme as it is (it reduced any scheme without exactly nine stops to nine evenly spaced ones, which made a lossy copy of the slimmed Inferno). A file loaded through "Load from file…" with more than 32 stops, one of the author's sampled tables, is slimmed to its bends on the way in (`ColorScheme.Simplify`, tolerance 3, logged), so 255 rows never reach the editor. **The colour picker** (2026-10-15, the user's choice of anin-house picker over the Windows dialog, which is not themed, has no live preview and cannot be driven by postedkeys): each stop row's swatch is a `Controls/ColorPickerButton` (a `ToggleButton`; Space, Enter or Down open apopup below it, id `StopSwatch:<position>`, the hex box beside it `StopColor:<position>`, both in the locale's@@ -993,7 +992,7 @@ progress and cancel are in, and the still of the shown frame; `library_check --cover them. Left: probe data as CSV (series per step, profiles per frame), an integer upscale for smallcanvases, HEVC (Media Foundation has it on some machines). Author's point 10.-**Also open, smaller.** Offer `ColorScheme.Simplify` in the editor; base64 vs BaseXML for the embedded image; the RAM-first frame store (numbers above);+**Also open, smaller.** base64 vs BaseXML for the embedded image; the RAM-first frame store (numbers above);dropping the 9-point Laplacian (author's suggestion, user undecided); timeline event tracks, zoom andpan (roadmap); dock pane titles are not exposed to UI Automation.diff --git a/WaveDudeNext.WPF/Commands/ColorSchemeCommands.cs b/WaveDudeNext.WPF/Commands/ColorSchemeCommands.csindex d437b52..f11cf42 100644--- a/WaveDudeNext.WPF/Commands/ColorSchemeCommands.cs+++ b/WaveDudeNext.WPF/Commands/ColorSchemeCommands.cs@@ -22,9 +22,6 @@ namespace WaveDudeNext.WPF.Commands;/// <summary>Commands of the colour scheme editor (<c>Views/ColorSchemeView</c>), bound on the view itself.</summary>public static class ColorSchemeCommands{- /// <summary>Turns a sampled 255-colour table into the author's 9 evenly spaced stops (<see cref="WaveDudeNext.Rendering.ColorScheme.ReduceToStops"/>).</summary>- public static readonly RoutedUICommand ReduceToStops = new("Reduce to stops", nameof(ReduceToStops), typeof(ColorSchemeCommands));-/// <summary>Adds a stop in the widest gap (<see cref="WaveDudeNext.Rendering.ColorScheme.AddStop"/>).</summary>public static readonly RoutedUICommand AddStop = new("Add stop", nameof(AddStop), typeof(ColorSchemeCommands));diff --git a/WaveDudeNext.WPF/Controls/ColorSchemePicker.cs b/WaveDudeNext.WPF/Controls/ColorSchemePicker.csindex 6442f7d..c319e52 100644--- a/WaveDudeNext.WPF/Controls/ColorSchemePicker.cs+++ b/WaveDudeNext.WPF/Controls/ColorSchemePicker.cs@@ -72,6 +72,10 @@ public enum PickerActionpublic sealed class ColorSchemePicker : ComboBox{private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();+ /// <summary>More stops than this on a loaded file means a sampled table, which is slimmed to its bends.</summary>+ private const int SampledTableStops = 32;+ /// <summary>The tolerance (largest channel difference, 0 to 255) the shipped colormaps were slimmed with.</summary>+ private const double SimplifyTolerance = 3;/// <summary>Identifies the <see cref="Project"/> property.</summary>public static readonly DependencyProperty ProjectProperty = DependencyProperty.Register(@@ -261,6 +265,14 @@ public sealed class ColorSchemePicker : ComboBox{ColorScheme scheme = ColorSchemeStore.LoadFile(dialog.FileName);scheme.FilePath = ""; // it lives in the project from now on+ // one of the author's sampled 255-colour tables keeps only its bends (the shipped ones were slimmed the same+ // way, tolerance 3 of 255): nobody edits 255 rows, and the look does not change+ if (scheme.Stops.Count > SampledTableStops)+ {+ int before = scheme.Stops.Count;+ scheme.Simplify(SimplifyTolerance);+ Logger.Info("Colour scheme '{Name}': {Before} sampled colours reduced to {After} stops", scheme.Name, before, scheme.Stops.Count);+ }project.AddColorScheme(scheme);SelectedName = scheme.Name;Logger.Info("Colour scheme '{Name}' loaded from '{Path}' into the project", scheme.Name, dialog.FileName);@@ -271,7 +283,7 @@ public sealed class ColorSchemePicker : ComboBox}}- /// <summary>Copies the scheme in use into the project as 9 stops, selects the copy and opens it in the Project tree.</summary>+ /// <summary>Copies the scheme in use into the project as it is, selects the copy and opens it in the Project tree.</summary>private void EditCopy(){if (Project is not { } project || ColorSchemeCatalog.Instance.Resolve(project, SelectedName) is not { } current)@@ -279,10 +291,6 @@ public sealed class ColorSchemePicker : ComboBoxreturn;}ColorScheme copy = current.Clone(current.Name + " copy");- if (!copy.IsStopScheme)- {- copy.ReduceToStops();- }if (project.ColorSchemes.Contains(current)){copy.Description = "copy of project scheme '" + current.Name + "'";diff --git a/WaveDudeNext.WPF/Strings/Strings.DE.xaml b/WaveDudeNext.WPF/Strings/Strings.DE.xamlindex f11dbf7..74e7a43 100644--- a/WaveDudeNext.WPF/Strings/Strings.DE.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.DE.xaml@@ -246,8 +246,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<s:String x:Key="PickerEditCopy">Kopie im Projekt bearbeiten…</s:String><s:String x:Key="PickerProjectTag">Projekt</s:String><s:String x:Key="PickerMissingFormat">{0} (nicht gefunden)</s:String>- <s:String x:Key="ButtonReduceToStops">Auf 9 Stützpunkte reduzieren</s:String>- <s:String x:Key="TipReduceToStops">9 gleichmäßig verteilte Farben aus dieser 255-Farben-Tabelle behalten; der Verlauf läuft dann gerade zwischen ihnen</s:String><s:String x:Key="LabelBasedOn">Vorlage</s:String><s:String x:Key="TipBasedOn">Übernimmt die Stützpunkte eines vorhandenen Schemas; danach anpassen</s:String><s:String x:Key="ButtonAddStop">Stützpunkt hinzufügen</s:String>diff --git a/WaveDudeNext.WPF/Strings/Strings.EN.xaml b/WaveDudeNext.WPF/Strings/Strings.EN.xamlindex 5619398..e31bb2e 100644--- a/WaveDudeNext.WPF/Strings/Strings.EN.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.EN.xaml@@ -248,8 +248,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<s:String x:Key="PickerEditCopy">Edit a copy in the project…</s:String><s:String x:Key="PickerProjectTag">project</s:String><s:String x:Key="PickerMissingFormat">{0} (not found)</s:String>- <s:String x:Key="ButtonReduceToStops">Reduce to 9 stops</s:String>- <s:String x:Key="TipReduceToStops">Keep 9 evenly spaced colours sampled from this 255-colour table; the gradient then runs straight between them</s:String><s:String x:Key="LabelBasedOn">Based on</s:String><s:String x:Key="TipBasedOn">Copy the stops of an existing scheme into this one, then change them</s:String><s:String x:Key="ButtonAddStop">Add stop</s:String>diff --git a/WaveDudeNext.WPF/Strings/Strings.FR.xaml b/WaveDudeNext.WPF/Strings/Strings.FR.xamlindex db1ab22..02561e6 100644--- a/WaveDudeNext.WPF/Strings/Strings.FR.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.FR.xaml@@ -246,8 +246,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<s:String x:Key="PickerEditCopy">Modifier une copie dans le projet…</s:String><s:String x:Key="PickerProjectTag">projet</s:String><s:String x:Key="PickerMissingFormat">{0} (introuvable)</s:String>- <s:String x:Key="ButtonReduceToStops">Réduire à 9 points</s:String>- <s:String x:Key="TipReduceToStops">Garder 9 couleurs régulièrement espacées, prélevées dans cette table de 255 couleurs ; le dégradé est alors linéaire entre elles</s:String><s:String x:Key="LabelBasedOn">Modèle</s:String><s:String x:Key="TipBasedOn">Copie les points d'une palette existante dans celle-ci, à adapter ensuite</s:String><s:String x:Key="ButtonAddStop">Ajouter un point</s:String>diff --git a/WaveDudeNext.WPF/Strings/Strings.NL.xaml b/WaveDudeNext.WPF/Strings/Strings.NL.xamlindex 9f164d5..49571a2 100644--- a/WaveDudeNext.WPF/Strings/Strings.NL.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.NL.xaml@@ -246,8 +246,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<s:String x:Key="PickerEditCopy">Een kopie in het project bewerken…</s:String><s:String x:Key="PickerProjectTag">project</s:String><s:String x:Key="PickerMissingFormat">{0} (niet gevonden)</s:String>- <s:String x:Key="ButtonReduceToStops">Terugbrengen tot 9 punten</s:String>- <s:String x:Key="TipReduceToStops">9 gelijkmatig verdeelde kleuren uit deze tabel van 255 kleuren behouden; het verloop loopt dan recht tussen die punten</s:String><s:String x:Key="LabelBasedOn">Gebaseerd op</s:String><s:String x:Key="TipBasedOn">Neemt de punten van een bestaand schema over; daarna aanpassen</s:String><s:String x:Key="ButtonAddStop">Punt toevoegen</s:String>diff --git a/WaveDudeNext.WPF/Views/ColorSchemeView.xaml b/WaveDudeNext.WPF/Views/ColorSchemeView.xamlindex 08cf185..533ee0f 100644--- a/WaveDudeNext.WPF/Views/ColorSchemeView.xaml+++ b/WaveDudeNext.WPF/Views/ColorSchemeView.xaml@@ -31,13 +31,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<converters:RgbBrushConverter x:Key="RgbBrush" /><StreamGeometry x:Key="MinusGeometry">M0,4 L8,4</StreamGeometry><!-- the "reduce" step applies to a sampled table only -->- <Style x:Key="TableOnly" TargetType="{x:Type FrameworkElement}">- <Style.Triggers>- <DataTrigger Binding="{Binding IsStopScheme}" Value="True">- <Setter Property="Visibility" Value="Collapsed" />- </DataTrigger>- </Style.Triggers>- </Style><Style x:Key="RemoveStopButton" TargetType="{x:Type Button}"><Setter Property="Width" Value="18" /><Setter Property="Height" Value="18" />@@ -67,7 +60,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or</UserControl.Resources><UserControl.CommandBindings>- <CommandBinding Command="{x:Static commands:ColorSchemeCommands.ReduceToStops}" CanExecute="CanReduce" Executed="OnReduce" /><CommandBinding Command="{x:Static commands:ColorSchemeCommands.AddStop}" CanExecute="CanAddStop" Executed="OnAddStop" /><CommandBinding Command="{x:Static commands:ColorSchemeCommands.RemoveStop}" CanExecute="CanRemoveStop" Executed="OnRemoveStop" /></UserControl.CommandBindings>@@ -132,9 +124,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<StackPanel Orientation="Horizontal"><Button Padding="8,2" Margin="0,2,6,0" Content="{DynamicResource ButtonAddStop}" ToolTip="{DynamicResource TipAddStop}"Command="{x:Static commands:ColorSchemeCommands.AddStop}" AutomationProperties.AutomationId="SchemeAddStop" />- <Button Style="{StaticResource TableOnly}" Padding="8,2" Margin="0,2,0,0" Content="{DynamicResource ButtonReduceToStops}"- ToolTip="{DynamicResource TipReduceToStops}" Command="{x:Static commands:ColorSchemeCommands.ReduceToStops}"- AutomationProperties.AutomationId="SchemeReduce" /></StackPanel></StackPanel></ScrollViewer>diff --git a/WaveDudeNext.WPF/Views/ColorSchemeView.xaml.cs b/WaveDudeNext.WPF/Views/ColorSchemeView.xaml.csindex d8bb147..253d7c5 100644--- a/WaveDudeNext.WPF/Views/ColorSchemeView.xaml.cs+++ b/WaveDudeNext.WPF/Views/ColorSchemeView.xaml.cs@@ -91,10 +91,6 @@ public partial class ColorSchemeView : UserControlscheme.Description = "copy of scheme '" + chosen.Name + "'";}- private void CanReduce(object sender, CanExecuteRoutedEventArgs e) => e.CanExecute = Scheme is { IsStopScheme: false };-- private void OnReduce(object sender, ExecutedRoutedEventArgs e) => Scheme?.ReduceToStops();-private void CanAddStop(object sender, CanExecuteRoutedEventArgs e) => e.CanExecute = Scheme != null;private void OnAddStop(object sender, ExecutedRoutedEventArgs e) => Scheme?.AddStop();diff --git a/WaveDudeNext/Rendering/ColorScheme.cs b/WaveDudeNext/Rendering/ColorScheme.csindex 6318730..ee33145 100644--- a/WaveDudeNext/Rendering/ColorScheme.cs+++ b/WaveDudeNext/Rendering/ColorScheme.cs@@ -97,8 +97,7 @@ public sealed class ColorStop : ObservableObject/// the author's files carried a 255-entry table plus, for the ones made in his editor, 9 evenly spaced/// stops; every shipped table equals the interpolation of its stops, so those schemes keep the 9 stops/// and the sampled colormaps keep 255 stops at i/254. Stops may sit anywhere (2026-10-13, the user's-/// call: positions are fractions of the gradient); <see cref="ReduceToStops"/> samples a table down to-/// the author's 9 evenly spaced ones. Serialises to XML as attributes plus one <c>Stop</c> element per+/// call: positions are fractions of the gradient). Serialises to XML as attributes plus one <c>Stop</c> element per/// stop, both standalone (<c>.wdscheme</c>) and inside a project file. Observable: a stop's edit raises/// <c>Stops</c> on the scheme. UI thread for edits; the derived table is read by anyone building a LUT./// </summary>@@ -312,26 +311,6 @@ public sealed class ColorScheme : ObservableObject/// <summary>Removes a stop; false when it is not here or the last one.</summary>public bool RemoveStop(ColorStop stop) => Stops.Count > 1 && Stops.Remove(stop);- /// <summary>- /// Turns a sampled table into the author's editable gradient: keeps 9 evenly spaced colours sampled- /// from the table (his "9-stop copy"); a scheme that already has 9 stops is left alone. The look- /// changes where the table was not linear between those points.- /// </summary>- public void ReduceToStops()- {- if (IsStopScheme)- {- return;- }- var stops = new Rgb[StopCount];- for (int i = 0; i < StopCount; i++)- {- stops[i] = SampleAt((i * (EntryCount - 1)) / (double)(StopCount - 1));- }- Description = StopCount.ToString(CultureInfo.InvariantCulture) + "-stop copy of scheme '" + Name + "'";- SetColors(stops);- }-/// <summary>/// Drops every stop that the straight line between its neighbours reproduces within/// <paramref name="tolerance"/> (the largest channel difference, 0..255, after the renderer's rounding):