|
@@ -19,46 +19,33 @@ internal class RasterLineToolExecutor : LineExecutor<ILineToolHandler>
|
|
|
|
|
|
protected override IAction DrawLine(VecD pos)
|
|
|
{
|
|
|
- VecD dir = GetSignedDirection(startDrawingPos, pos);
|
|
|
- VecD oppositeDir = new VecD(-dir.X, -dir.Y);
|
|
|
- return new DrawRasterLine_Action(memberId, ToPixelPos(startDrawingPos, oppositeDir), ToPixelPos(pos, dir), (float)StrokeWidth,
|
|
|
- StrokePaintable, StrokeCap.Butt, toolbar.AntiAliasing, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
|
|
|
+ return new DrawRasterLine_Action(memberId, ToPixelPos(startDrawingPos), ToPixelPos(pos),
|
|
|
+ (float)StrokeWidth,
|
|
|
+ StrokePaintable, StrokeCap.Butt, toolbar.AntiAliasing, drawOnMask,
|
|
|
+ document!.AnimationHandler.ActiveFrameBindable);
|
|
|
}
|
|
|
|
|
|
protected override IAction TransformOverlayMoved(VecD start, VecD end)
|
|
|
{
|
|
|
- VecD dir = GetSignedDirection(start, end);
|
|
|
- VecD oppositeDir = new VecD(-dir.X, -dir.Y);
|
|
|
- return new DrawRasterLine_Action(memberId, ToPixelPos(start, oppositeDir), ToPixelPos(end, dir),
|
|
|
- (float)StrokeWidth, StrokePaintable, StrokeCap.Butt, toolbar.AntiAliasing, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
|
|
|
+ return new DrawRasterLine_Action(memberId, ToPixelPos(start), ToPixelPos(end),
|
|
|
+ (float)StrokeWidth, StrokePaintable, StrokeCap.Butt, toolbar.AntiAliasing, drawOnMask,
|
|
|
+ document!.AnimationHandler.ActiveFrameBindable);
|
|
|
}
|
|
|
|
|
|
protected override IAction[] SettingsChange(string name, object value)
|
|
|
{
|
|
|
- VecD dir = GetSignedDirection(startDrawingPos, curPos);
|
|
|
- VecD oppositeDir = new VecD(-dir.X, -dir.Y);
|
|
|
- return [new DrawRasterLine_Action(memberId, ToPixelPos(startDrawingPos, oppositeDir), ToPixelPos(curPos, dir), (float)StrokeWidth,
|
|
|
- StrokePaintable, StrokeCap.Butt, toolbar.AntiAliasing, drawOnMask, document!.AnimationHandler.ActiveFrameBindable)];
|
|
|
+ return
|
|
|
+ [
|
|
|
+ new DrawRasterLine_Action(memberId, ToPixelPos(startDrawingPos), ToPixelPos(curPos),
|
|
|
+ (float)StrokeWidth,
|
|
|
+ StrokePaintable, StrokeCap.Butt, toolbar.AntiAliasing, drawOnMask,
|
|
|
+ document!.AnimationHandler.ActiveFrameBindable)
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
- private VecI ToPixelPos(VecD pos, VecD dir)
|
|
|
+ private VecD ToPixelPos(VecD pos)
|
|
|
{
|
|
|
- if (StrokeWidth > 1) return (VecI)pos.Round();
|
|
|
-
|
|
|
- double xAdjustment = dir.X > 0 ? 0.5 : -0.5;
|
|
|
- double yAdjustment = dir.Y > 0 ? 0.5 : -0.5;
|
|
|
-
|
|
|
- VecD adjustment = new VecD(xAdjustment, yAdjustment);
|
|
|
-
|
|
|
-
|
|
|
- VecI finalPos = (VecI)(pos - adjustment);
|
|
|
-
|
|
|
- return finalPos;
|
|
|
- }
|
|
|
-
|
|
|
- private VecD GetSignedDirection(VecD start, VecD end)
|
|
|
- {
|
|
|
- return new VecD(Math.Sign(end.X - start.X), Math.Sign(end.Y - start.Y));
|
|
|
+ return (VecD)pos;
|
|
|
}
|
|
|
|
|
|
protected override IAction EndDraw()
|