Skip to content

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#

A graph box is shrunk only when it is larger than the canvas

Alexander Graefe0ba11cf2fd0
diff --git a/WaveDudeNext.WPF/Strings/Strings.DE.xaml b/WaveDudeNext.WPF/Strings/Strings.DE.xaml
index 5eda585..3688858 100644
--- a/WaveDudeNext.WPF/Strings/Strings.DE.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.DE.xaml
@@ -321,15 +321,15 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Label.Probe.BY">B y</s:String>
<s:String x:Key="Hint.Probe.BY">Y des Linienendes in Leinwandpixeln; nur Liniensonden.</s:String>
<s:String x:Key="Label.Probe.BoxSize">Kastengröße</s:String>
- <s:String x:Key="Hint.Probe.BoxSize">Nenngröße des Diagrammkastens über der Ausgabe.</s:String>
+ <s:String x:Key="Hint.Probe.BoxSize">Nenngröße des Diagrammkastens über der Ausgabe; ein Kasten größer als die Leinwand wird seitenverhältnistreu auf sie verkleinert.</s:String>
<s:String x:Key="Label.Probe.BoxX">Kasten x</s:String>
<s:String x:Key="Hint.Probe.BoxX">Linker Rand des Diagrammkastens in Leinwandpixeln. Ein Kasten auf Punkt A der Sonde wandert mit ihr; in die Nähe gezogen rastet er dort ein.</s:String>
<s:String x:Key="Label.Probe.BoxY">Kasten y</s:String>
<s:String x:Key="Hint.Probe.BoxY">Oberer Rand des Diagrammkastens in Leinwandpixeln. Ein Kasten auf Punkt A der Sonde wandert mit ihr; in die Nähe gezogen rastet er dort ein.</s:String>
<s:String x:Key="Label.Probe.BoxWidth">Kastenbreite</s:String>
- <s:String x:Key="Hint.Probe.BoxWidth">Breite des Diagrammkastens in Leinwandpixeln; nur bei eigener Kastengröße.</s:String>
+ <s:String x:Key="Hint.Probe.BoxWidth">Breite des Diagrammkastens in Leinwandpixeln; nur bei eigener Kastengröße. Ein Kasten größer als die Leinwand wird seitenverhältnistreu auf sie verkleinert.</s:String>
<s:String x:Key="Label.Probe.BoxHeight">Kastenhöhe</s:String>
- <s:String x:Key="Hint.Probe.BoxHeight">Höhe des Diagrammkastens in Leinwandpixeln; nur bei eigener Kastengröße.</s:String>
+ <s:String x:Key="Hint.Probe.BoxHeight">Höhe des Diagrammkastens in Leinwandpixeln; nur bei eigener Kastengröße. Ein Kasten größer als die Leinwand wird seitenverhältnistreu auf sie verkleinert.</s:String>
<s:String x:Key="Label.Probe.ScaleMode">Schrittachse</s:String>
<s:String x:Key="Hint.Probe.ScaleMode">Gleitendes Fenster der letzten Schritte oder der ganze Lauf; nur Punktsonden.</s:String>
<s:String x:Key="Label.Probe.AutoScaleX">Schritte automatisch skalieren</s:String>
diff --git a/WaveDudeNext.WPF/Strings/Strings.EN.xaml b/WaveDudeNext.WPF/Strings/Strings.EN.xaml
index ec73ee0..e71bbb0 100644
--- a/WaveDudeNext.WPF/Strings/Strings.EN.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.EN.xaml
@@ -323,15 +323,15 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Label.Probe.BY">B y</s:String>
<s:String x:Key="Hint.Probe.BY">Y of the end of the line in canvas pixels; line probes only.</s:String>
<s:String x:Key="Label.Probe.BoxSize">Box size</s:String>
- <s:String x:Key="Hint.Probe.BoxSize">Nominal size of the graph box drawn over the output.</s:String>
+ <s:String x:Key="Hint.Probe.BoxSize">Nominal size of the graph box drawn over the output; a box larger than the canvas is shrunk to fit it, aspect kept.</s:String>
<s:String x:Key="Label.Probe.BoxX">Box x</s:String>
<s:String x:Key="Hint.Probe.BoxX">Left edge of the graph box in canvas pixels. A box placed on the probe's point A moves with the probe; dragging it close snaps it on.</s:String>
<s:String x:Key="Label.Probe.BoxY">Box y</s:String>
<s:String x:Key="Hint.Probe.BoxY">Top edge of the graph box in canvas pixels. A box placed on the probe's point A moves with the probe; dragging it close snaps it on.</s:String>
<s:String x:Key="Label.Probe.BoxWidth">Box width</s:String>
- <s:String x:Key="Hint.Probe.BoxWidth">Width of the graph box in canvas pixels; custom box size only.</s:String>
+ <s:String x:Key="Hint.Probe.BoxWidth">Width of the graph box in canvas pixels; custom box size only. A box larger than the canvas is shrunk to fit it, aspect kept.</s:String>
<s:String x:Key="Label.Probe.BoxHeight">Box height</s:String>
- <s:String x:Key="Hint.Probe.BoxHeight">Height of the graph box in canvas pixels; custom box size only.</s:String>
+ <s:String x:Key="Hint.Probe.BoxHeight">Height of the graph box in canvas pixels; custom box size only. A box larger than the canvas is shrunk to fit it, aspect kept.</s:String>
<s:String x:Key="Label.Probe.ScaleMode">Step axis</s:String>
<s:String x:Key="Hint.Probe.ScaleMode">Sliding window of the last steps, or the whole run; point probes only.</s:String>
<s:String x:Key="Label.Probe.AutoScaleX">Auto-scale steps</s:String>
diff --git a/WaveDudeNext.WPF/Strings/Strings.FR.xaml b/WaveDudeNext.WPF/Strings/Strings.FR.xaml
index 1d709fa..706d009 100644
--- a/WaveDudeNext.WPF/Strings/Strings.FR.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.FR.xaml
@@ -321,15 +321,15 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Label.Probe.BY">B y</s:String>
<s:String x:Key="Hint.Probe.BY">Y de la fin de la ligne en pixels de toile ; sondes linéaires seulement.</s:String>
<s:String x:Key="Label.Probe.BoxSize">Taille du cadre</s:String>
- <s:String x:Key="Hint.Probe.BoxSize">Taille nominale du cadre du graphique dessiné sur la sortie.</s:String>
+ <s:String x:Key="Hint.Probe.BoxSize">Taille nominale du cadre du graphique dessiné sur la sortie ; un cadre plus grand que la toile est réduit à sa taille, proportions conservées.</s:String>
<s:String x:Key="Label.Probe.BoxX">Cadre x</s:String>
<s:String x:Key="Hint.Probe.BoxX">Bord gauche du cadre du graphique en pixels de toile. Un cadre posé sur le point A de la sonde la suit ; approché en le glissant, il s'y accroche.</s:String>
<s:String x:Key="Label.Probe.BoxY">Cadre y</s:String>
<s:String x:Key="Hint.Probe.BoxY">Bord supérieur du cadre du graphique en pixels de toile. Un cadre posé sur le point A de la sonde la suit ; approché en le glissant, il s'y accroche.</s:String>
<s:String x:Key="Label.Probe.BoxWidth">Largeur du cadre</s:String>
- <s:String x:Key="Hint.Probe.BoxWidth">Largeur du cadre du graphique en pixels de toile ; taille personnalisée seulement.</s:String>
+ <s:String x:Key="Hint.Probe.BoxWidth">Largeur du cadre du graphique en pixels de toile ; taille personnalisée seulement. Un cadre plus grand que la toile est réduit à sa taille, proportions conservées.</s:String>
<s:String x:Key="Label.Probe.BoxHeight">Hauteur du cadre</s:String>
- <s:String x:Key="Hint.Probe.BoxHeight">Hauteur du cadre du graphique en pixels de toile ; taille personnalisée seulement.</s:String>
+ <s:String x:Key="Hint.Probe.BoxHeight">Hauteur du cadre du graphique en pixels de toile ; taille personnalisée seulement. Un cadre plus grand que la toile est réduit à sa taille, proportions conservées.</s:String>
<s:String x:Key="Label.Probe.ScaleMode">Axe des pas</s:String>
<s:String x:Key="Hint.Probe.ScaleMode">Fenêtre glissante des derniers pas, ou toute l'exécution ; sondes ponctuelles seulement.</s:String>
<s:String x:Key="Label.Probe.AutoScaleX">Échelle auto des pas</s:String>
diff --git a/WaveDudeNext.WPF/Strings/Strings.NL.xaml b/WaveDudeNext.WPF/Strings/Strings.NL.xaml
index 5a38ed1..125c5fb 100644
--- a/WaveDudeNext.WPF/Strings/Strings.NL.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.NL.xaml
@@ -321,15 +321,15 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Label.Probe.BY">B y</s:String>
<s:String x:Key="Hint.Probe.BY">Y van het einde van de lijn in canvaspixels; alleen lijnsondes.</s:String>
<s:String x:Key="Label.Probe.BoxSize">Kadergrootte</s:String>
- <s:String x:Key="Hint.Probe.BoxSize">Nominale grootte van het grafiekkader over de uitvoer.</s:String>
+ <s:String x:Key="Hint.Probe.BoxSize">Nominale grootte van het grafiekkader over de uitvoer; een kader groter dan het canvas wordt met behoud van de verhouding tot het canvas verkleind.</s:String>
<s:String x:Key="Label.Probe.BoxX">Kader x</s:String>
<s:String x:Key="Hint.Probe.BoxX">Linkerrand van het grafiekkader in canvaspixels. Een kader op punt A van de sonde beweegt met haar mee; dichtbij gesleept klikt het daar vast.</s:String>
<s:String x:Key="Label.Probe.BoxY">Kader y</s:String>
<s:String x:Key="Hint.Probe.BoxY">Bovenrand van het grafiekkader in canvaspixels. Een kader op punt A van de sonde beweegt met haar mee; dichtbij gesleept klikt het daar vast.</s:String>
<s:String x:Key="Label.Probe.BoxWidth">Kaderbreedte</s:String>
- <s:String x:Key="Hint.Probe.BoxWidth">Breedte van het grafiekkader in canvaspixels; alleen bij een eigen kadermaat.</s:String>
+ <s:String x:Key="Hint.Probe.BoxWidth">Breedte van het grafiekkader in canvaspixels; alleen bij een eigen kadermaat. Een kader groter dan het canvas wordt met behoud van de verhouding tot het canvas verkleind.</s:String>
<s:String x:Key="Label.Probe.BoxHeight">Kaderhoogte</s:String>
- <s:String x:Key="Hint.Probe.BoxHeight">Hoogte van het grafiekkader in canvaspixels; alleen bij een eigen kadermaat.</s:String>
+ <s:String x:Key="Hint.Probe.BoxHeight">Hoogte van het grafiekkader in canvaspixels; alleen bij een eigen kadermaat. Een kader groter dan het canvas wordt met behoud van de verhouding tot het canvas verkleind.</s:String>
<s:String x:Key="Label.Probe.ScaleMode">Stappenas</s:String>
<s:String x:Key="Hint.Probe.ScaleMode">Schuivend venster van de laatste stappen, of de hele run; alleen puntsondes.</s:String>
<s:String x:Key="Label.Probe.AutoScaleX">Stappen automatisch schalen</s:String>
diff --git a/WaveDudeNext/Model/Probe.cs b/WaveDudeNext/Model/Probe.cs
index 0d1c569..91364cb 100644
--- a/WaveDudeNext/Model/Probe.cs
+++ b/WaveDudeNext/Model/Probe.cs
@@ -260,7 +260,7 @@ public sealed class Probe : ObservableObject
[DefaultValue(ProbeBoxSize.Medium)]
[Category("Graph")]
[DisplayName("Box size")]
- [Description("Nominal size of the graph box drawn over the output.")]
+ [Description("Nominal size of the graph box drawn over the output; a box larger than the canvas is shrunk to fit it, aspect kept.")]
public ProbeBoxSize BoxSize
{
get => _boxSize;
@@ -296,7 +296,7 @@ public sealed class Probe : ObservableObject
[DefaultValue(DefaultBoxWidth)]
[Category("Graph")]
[DisplayName("Box width")]
- [Description("Width of the graph box in canvas pixels; custom box size only.")]
+ [Description("Width of the graph box in canvas pixels; custom box size only. A box larger than the canvas is shrunk to fit it, aspect kept.")]
public int BoxWidth
{
get => _boxWidth;
@@ -308,7 +308,7 @@ public sealed class Probe : ObservableObject
[DefaultValue(DefaultBoxHeight)]
[Category("Graph")]
[DisplayName("Box height")]
- [Description("Height of the graph box in canvas pixels; custom box size only.")]
+ [Description("Height of the graph box in canvas pixels; custom box size only. A box larger than the canvas is shrunk to fit it, aspect kept.")]
public int BoxHeight
{
get => _boxHeight;
diff --git a/WaveDudeNext/Probes/ProbeGraph.cs b/WaveDudeNext/Probes/ProbeGraph.cs
index f010a9e..b1b3382 100644
--- a/WaveDudeNext/Probes/ProbeGraph.cs
+++ b/WaveDudeNext/Probes/ProbeGraph.cs
@@ -198,9 +198,10 @@ public static class ProbeGraph
: NominalBoxSize(probe.BoxSize);
/// <summary>
- /// The graph box of a probe on a canvas: its size, shrunk (keeping the aspect ratio) so it fits into half
- /// the canvas width and the full canvas height, placed at the probe's box position and clamped to stay
- /// inside the canvas.
+ /// The graph box of a probe on a canvas: its size, shrunk (keeping the aspect ratio) only when it is wider
+ /// or taller than the canvas, placed at the probe's box position and clamped to stay inside the canvas. Until
+ /// 2026-10-18 a box was held to half the canvas width (Wave Dude 2D's rule for its fixed sizes), which cut a
+ /// custom size below the typed values without a word.
/// </summary>
/// <param name="probe">Provides the box size and the wanted position.</param>
/// <param name="w">Canvas width in pixels.</param>
@@ -210,9 +211,9 @@ public static class ProbeGraph
{
BoxSize nominal = BoxSizeOf(probe);
double scale = 1.0;
- if (nominal.Width > w / 2.0)
+ if (nominal.Width > w)
{
- scale = Math.Min(scale, w / 2.0 / nominal.Width);
+ scale = Math.Min(scale, (double)w / nominal.Width);
}
if (nominal.Height > h)
{
diff --git a/_tools/library_check/Program.cs b/_tools/library_check/Program.cs
index 9ba7a26..e8b9e21 100644
--- a/_tools/library_check/Program.cs
+++ b/_tools/library_check/Program.cs
@@ -1320,11 +1320,17 @@ internal static class Program
follower.AX = 75;
Check(follower.IsBoxAttached && follower.BoxX == 75 && follower.BoxY == 61, "a box put back on the probe is attached again");
Check(ProbeGraph.BoxInCanvas(probe, 1920, 1080) == new BoxRect(1520, 880, 400, 200), "box clamped into a full-HD canvas");
- Check(ProbeGraph.BoxInCanvas(probe, 64, 48) == new BoxRect(32, 32, 32, 16), "box shrunk to half the width of a 64 x 48 canvas, aspect kept");
+ Check(ProbeGraph.BoxInCanvas(probe, 64, 48) == new BoxRect(0, 16, 64, 32), "box shrunk to the width of a 64 x 48 canvas, aspect kept");
probe.BoxSize = ProbeBoxSize.Custom;
probe.BoxWidth = 500;
probe.BoxHeight = 100;
Check(ProbeGraph.BoxSizeOf(probe) == new BoxSize(500, 100) && ProbeGraph.BoxInCanvas(probe, 1920, 1080) == new BoxRect(1420, 900, 500, 100), "custom box size used as it is");
+ probe.BoxWidth = 1200;
+ probe.BoxHeight = 300;
+ Check(ProbeGraph.BoxInCanvas(probe, 1920, 1080) == new BoxRect(720, 780, 1200, 300), "a custom box wider than half the canvas is drawn at its size (it was held to half the width until 2026-10-18)");
+ probe.BoxWidth = 3000;
+ probe.BoxHeight = 600;
+ Check(ProbeGraph.BoxInCanvas(probe, 1920, 1080) == new BoxRect(0, 696, 1920, 384), "a custom box wider than the canvas is shrunk to its width, aspect kept");
Check(ProbeGraph.Snap(405, 195) == (ProbeBoxSize.Medium, new BoxSize(400, 200)) && ProbeGraph.Snap(690, 360) == (ProbeBoxSize.ExtraLarge, new BoxSize(700, 350)), "a dragged size near a preset snaps to it");
Check(ProbeGraph.Snap(450, 230) == (ProbeBoxSize.Custom, new BoxSize(450, 230)) && ProbeGraph.Snap(10, 10) == (ProbeBoxSize.Custom, new BoxSize(60, 30)), "other sizes stay custom, clamped to the minimum");
Check(ProbeGraph.NiceTicks(-1, 1, 4).SequenceEqual([-1.0, -0.5, 0.0, 0.5, 1.0]) && ProbeGraph.NiceTicks(0, 2500, 5).SequenceEqual([0.0, 500.0, 1000.0, 1500.0, 2000.0, 2500.0]), "nice ticks at 1/2/5 steps, zero exact");