[WIP] Scaling
Test / Run tests (push) Successful in 16s

This commit is contained in:
2026-08-13 18:15:58 +02:00
parent 2dee3a9ae9
commit 36c1ced254
24 changed files with 649 additions and 537 deletions
+25 -49
View File
@@ -15,10 +15,15 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public (bool TowardEnd, double PathOffset)? Flow { get; set; }
public double FlowLength => _flowArrows?.Length ?? 0;
private Line? _outer1;
private Line? _outer2;
private Line? _inner1;
private Line? _inner2;
public double X1 => Start.CenterX;
public double Y1 => Start.CenterY;
public double X2 => Start.CenterX;
public double Y2 => Orientation ? Sink.CenterY - 2 : Sink.TopY - 2;
public double X3 => Orientation ? Sink.CenterX : Start.CenterX + (Start.CenterX == End.CenterX ? 0 : Start.CenterX > End.CenterX ? -4 : 4);
public double Y3 => Orientation ? Sink.CenterY - 2 : Sink.TopY + 4;
private Polyline? _outer;
private Polyline? _inner;
private FlowArrows? _flowArrows;
public Inlet(INode start, ISink end, bool orientation = false) {
@@ -28,62 +33,33 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var x1 = Start.CenterX;
var y1 = Start.CenterY;
var x2 = Start.CenterX;
var y2 = Orientation ? Sink.CenterY - 10 : Sink.TopY - 10;
var x3 = Orientation ? Sink.CenterX : Start.CenterX + (Start.CenterX == End.CenterX ? 0 : Start.CenterX > End.CenterX ? -20 : 20);
var y3 = Orientation ? Sink.CenterY - 10 : Sink.TopY + 20;
_outer1 = new Line() {
X1 = x1,
Y1 = y1,
X2 = x2,
Y2 = y2,
StrokeThickness = 10,
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
};
_inner1 = new Line() {
X1 = x1,
Y1 = y1,
X2 = x2,
Y2 = y2,
StrokeThickness = 6,
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
};
_outer2 = new Line() {
X1 = x2,
Y1 = y2,
X2 = x3,
Y2 = y3,
StrokeThickness = 10,
_outer = new Polyline() {
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeLineJoin = PenLineJoin.Round,
StrokeEndLineCap = PenLineCap.Flat,
};
_inner2 = new Line() {
X1 = x2,
Y1 = y2,
X2 = x3,
Y2 = y3,
StrokeThickness = 6,
_inner = new Polyline() {
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeLineJoin = PenLineJoin.Round,
StrokeEndLineCap = PenLineCap.Flat,
};
canvas.Children.Add(_outer1);
canvas.Children.Add(_outer2);
canvas.Children.Add(_inner1);
canvas.Children.Add(_inner2);
_flowArrows = FlowArrows.Create(canvas, _inner1!, _inner2!);
canvas.Children.Add(_outer);
canvas.Children.Add(_inner);
_flowArrows = FlowArrows.Create(canvas, _inner);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_outer?.Points = [Graph.ToPx(X1, Y1, scale), Graph.ToPx(X2, Y2, scale), Graph.ToPx(X3, Y3, scale)];
_inner?.Points = [Graph.ToPx(X1, Y1, scale), Graph.ToPx(X2, Y2, scale), Graph.ToPx(X3, Y3, scale)];
_inner?.StrokeThickness = Math.Round(1.2 * scale / 2) * 2;
_outer?.StrokeThickness = Math.Round(1.2 * scale / 2) * 2 + border * 2;
}
public void Update() {
_inner1?.Stroke = Highlight ?? Brushes.DarkGray;
_inner2?.Stroke = Highlight ?? Brushes.DarkGray;
_inner?.Stroke = Highlight ?? Brushes.DarkGray;
_flowArrows?.Update(Flow);
}
}