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 size grip or point handle follows the mouse absolutely
Alexander Graef704effddcc23
diff --git a/WaveDudeNext.WPF/Controls/MarkerThumb.cs b/WaveDudeNext.WPF/Controls/MarkerThumb.csindex ee928f4..afeb5c0 100644--- a/WaveDudeNext.WPF/Controls/MarkerThumb.cs+++ b/WaveDudeNext.WPF/Controls/MarkerThumb.cs@@ -118,4 +118,10 @@ public sealed class MarkerThumb : Thumb/// <summary>Mouse movement since the drag started, in canvas pixels.</summary>internal double DragDeltaY { get; set; }++ /// <summary>For a grip or point handle: where the mouse took hold, relative to the handle's canvas position (canvas pixels), so the handle keeps that grip while it follows the mouse.</summary>+ internal double GrabOffsetX { get; set; }++ /// <summary>For a grip or point handle: the vertical part of the grab offset (canvas pixels).</summary>+ internal double GrabOffsetY { get; set; }}diff --git a/WaveDudeNext.WPF/Controls/SceneOverlay.cs b/WaveDudeNext.WPF/Controls/SceneOverlay.csindex 8041e9f..e90415b 100644--- a/WaveDudeNext.WPF/Controls/SceneOverlay.cs+++ b/WaveDudeNext.WPF/Controls/SceneOverlay.cs@@ -450,6 +450,15 @@ public sealed class SceneOverlay : Panelreturn new Point(originX + x * scale, originY + y * scale);}+ /// <summary>The inverse of <see cref="ToViewExact"/> at the current size: a point of this element as continuous canvas coordinates (may lie outside the canvas).</summary>+ private (double X, double Y) ToCanvasExact(Point view)+ {+ double scale = Scale;+ double originX = (RenderSize.Width - CanvasWidth * scale) / 2;+ double originY = (RenderSize.Height - CanvasHeight * scale) / 2;+ return ((view.X - originX) / scale, (view.Y - originY) / scale);+ }+// ---------------------------------------------------------------- a part's grip and points/// <summary>The point list a part's handles edit: an outline's or a fibre's; null for the other kinds.</summary>@@ -777,6 +786,12 @@ public sealed class SceneOverlay : Panel(thumb.DragStartX, thumb.DragStartY) = PointOf(thumb);thumb.DragDeltaX = 0;thumb.DragDeltaY = 0;+ if (thumb.Role is MarkerRole.PartGrip or MarkerRole.PartPoint && CanvasOf(thumb) is { } handle)+ {+ (double mouseX, double mouseY) = ToCanvasExact(Mouse.GetPosition(this));+ thumb.GrabOffsetX = mouseX - handle.X;+ thumb.GrabOffsetY = mouseY - handle.Y;+ }SelectedItem = thumb.Item;thumb.Focus();}@@ -795,6 +810,15 @@ public sealed class SceneOverlay : PanelSetAngle(thumb.Item, Mouse.GetPosition(this), (Keyboard.Modifiers & ModifierKeys.Shift) != 0);return;}+ if (thumb.Role is MarkerRole.PartGrip or MarkerRole.PartPoint)+ {+ // absolute, from the mouse: a grip does not land under the mouse (a polygon's vertex stays on its ray, a+ // rectangle's corner on the positive quadrant), so thumb-relative deltas fed the miss back into the size+ // and a quick drag blew a hexagon up to the canvas (2026-10-19)+ (double mouseX, double mouseY) = ToCanvasExact(Mouse.GetPosition(this));+ SetPoint(thumb, (int)Math.Round(mouseX - thumb.GrabOffsetX), (int)Math.Round(mouseY - thumb.GrabOffsetY));+ return;+ }thumb.DragDeltaX += e.HorizontalChange / scale;thumb.DragDeltaY += e.VerticalChange / scale;SetPoint(thumb, thumb.DragStartX + (int)Math.Round(thumb.DragDeltaX), thumb.DragStartY + (int)Math.Round(thumb.DragDeltaY));