improve:墨迹平滑方案

This commit is contained in:
2025-07-20 15:21:59 +08:00
parent 428b278c78
commit d5142ad82c
8 changed files with 479 additions and 12 deletions
+31 -1
View File
@@ -433,6 +433,7 @@ namespace Ink_Canvas {
#region
private void MouseTouchMove(Point endP) {
// 禁用原有的FitToCurve,使用新的高级贝塞尔曲线平滑
if (Settings.Canvas.FitToCurve == true) drawingAttributes.FitToCurve = false;
ViewboxFloatingBar.IsHitTestVisible = false;
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
@@ -1589,7 +1590,36 @@ namespace Ink_Canvas {
}
}
if (Settings.Canvas.FitToCurve == true) drawingAttributes.FitToCurve = true;
// 应用高级贝塞尔曲线平滑
if (Settings.Canvas.UseAdvancedBezierSmoothing)
{
try
{
var advancedSmoothing = new Helpers.AdvancedBezierSmoothing
{
SmoothingStrength = Settings.Canvas.AdvancedSmoothingStrength,
Tension = Settings.Canvas.AdvancedSmoothingTension,
EnableAdaptiveSmoothing = Settings.Canvas.EnableAdaptiveSmoothing
};
// 对临时笔画应用平滑
if (lastTempStroke != null)
{
var smoothedStroke = advancedSmoothing.SmoothStroke(lastTempStroke);
inkCanvas.Strokes.Remove(lastTempStroke);
lastTempStroke = smoothedStroke;
inkCanvas.Strokes.Add(smoothedStroke);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"形状绘制高级贝塞尔曲线平滑失败: {ex.Message}");
}
}
else if (Settings.Canvas.FitToCurve == true)
{
drawingAttributes.FitToCurve = true;
}
}
private bool NeedUpdateIniP() {