|
@@ -16,22 +16,45 @@ internal class RasterLineToolExecutor : LineExecutor<ILineToolHandler>
|
|
|
|
|
|
protected override IAction DrawLine(VecD pos)
|
|
protected override IAction DrawLine(VecD pos)
|
|
{
|
|
{
|
|
- return new DrawRasterLine_Action(memberId, (VecI)startDrawingPos.Floor(), (VecI)pos.Floor(), StrokeWidth,
|
|
|
|
|
|
+ VecD dir = GetSignedDirection(startDrawingPos, pos);
|
|
|
|
+ VecD oppositeDir = new VecD(-dir.X, -dir.Y);
|
|
|
|
+ return new DrawRasterLine_Action(memberId, ToPixelPos(startDrawingPos, oppositeDir), ToPixelPos(pos, dir), StrokeWidth,
|
|
StrokeColor, StrokeCap.Butt, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
|
|
StrokeColor, StrokeCap.Butt, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
|
|
}
|
|
}
|
|
|
|
|
|
protected override IAction TransformOverlayMoved(VecD start, VecD end)
|
|
protected override IAction TransformOverlayMoved(VecD start, VecD end)
|
|
{
|
|
{
|
|
- return new DrawRasterLine_Action(memberId, (VecI)start, (VecI)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),
|
|
StrokeWidth, StrokeColor, StrokeCap.Butt, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
|
|
StrokeWidth, StrokeColor, StrokeCap.Butt, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
|
|
}
|
|
}
|
|
|
|
|
|
protected override IAction SettingsChange()
|
|
protected override IAction SettingsChange()
|
|
{
|
|
{
|
|
- return new DrawRasterLine_Action(memberId, (VecI)startDrawingPos.Floor(), (VecI)curPos.Floor(), StrokeWidth,
|
|
|
|
|
|
+ VecD dir = GetSignedDirection(startDrawingPos, curPos);
|
|
|
|
+ VecD oppositeDir = new VecD(-dir.X, -dir.Y);
|
|
|
|
+ return new DrawRasterLine_Action(memberId, ToPixelPos(startDrawingPos, oppositeDir), ToPixelPos(curPos, dir), StrokeWidth,
|
|
StrokeColor, StrokeCap.Butt, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
|
|
StrokeColor, StrokeCap.Butt, drawOnMask, document!.AnimationHandler.ActiveFrameBindable);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private VecI ToPixelPos(VecD pos, VecD dir)
|
|
|
|
+ {
|
|
|
|
+ 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));
|
|
|
|
+ }
|
|
|
|
+
|
|
protected override IAction EndDraw()
|
|
protected override IAction EndDraw()
|
|
{
|
|
{
|
|
return new EndDrawRasterLine_Action();
|
|
return new EndDrawRasterLine_Action();
|