Skip to content

Commit

Permalink
PenTool improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
flabbet committed Nov 19, 2021
1 parent 6ea4a16 commit b4bca30
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
37 changes: 25 additions & 12 deletions PixiEditor/Models/Controllers/BitmapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,32 @@ private void HighlightPixels(Coordinates newPosition)
{
previewLayerSize = ToolSize;
halfSize = (int)Math.Floor(ToolSize / 2f);
float sizeMod = ToolSize % 2 == 0 ? 0 : 0.5f;
AdjustOffset(newPosition, previewLayer);
int centerX = newPosition.X - previewLayer.OffsetX;
int centerY = newPosition.Y - previewLayer.OffsetY;

previewLayer.CreateNewBitmap(ToolSize, ToolSize);
previewLayer.LayerBitmap.SkiaSurface.Canvas
.DrawOval(
centerX,
centerY,
halfSize + sizeMod,
halfSize + sizeMod,
_highlightPaint);

if (ToolSize != 3)
{
float sizeMod = ToolSize % 2 == 0 ? 0 : 0.5f;
if (ToolSize == 1)
{
sizeMod = 1;
}

AdjustOffset(newPosition, previewLayer);
int centerX = newPosition.X - previewLayer.OffsetX;
int centerY = newPosition.Y - previewLayer.OffsetY;

previewLayer.LayerBitmap.SkiaSurface.Canvas
.DrawOval(
centerX,
centerY,
halfSize + sizeMod,
halfSize + sizeMod,
_highlightPaint);
}
else
{
previewLayer.LayerBitmap.SkiaSurface.Canvas.Clear(_highlightPaint.Color);
}

previewLayer.InvokeLayerBitmapChange();
}
Expand Down
2 changes: 1 addition & 1 deletion PixiEditor/Models/Tools/Tools/PenTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override void Use(Layer layer, List<Coordinates> coordinates, SKColor col
SKBlendMode blendMode = SKBlendMode.Src)
{

SKStrokeCap cap = toolSize == 1 ? SKStrokeCap.Square : SKStrokeCap.Round;
SKStrokeCap cap = toolSize == 1 || toolSize == 3 ? SKStrokeCap.Square : SKStrokeCap.Round;
if (!pixelPerfect)
{
lineTool.DrawLine(layer, startingCoords, latestCords, color, toolSize, blendMode, cap);
Expand Down

0 comments on commit b4bca30

Please sign in to comment.