mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 14:11:38 +12:00
Added line & arrow shadow
This commit is contained in:
parent
5e14b35eb7
commit
678ef0b1b0
|
@ -32,21 +32,12 @@ public class ArrowDrawingShape : LineDrawingShape
|
|||
{
|
||||
public override ShapeType ShapeType { get; } = ShapeType.DrawingArrow;
|
||||
|
||||
protected override void DrawLine(Graphics g, Pen pen)
|
||||
protected override Pen CreatePen(Color borderColor, int borderSize)
|
||||
{
|
||||
using (AdjustableArrowCap arrowCap = new AdjustableArrowCap(4, 6))
|
||||
return new Pen(borderColor, borderSize)
|
||||
{
|
||||
pen.CustomEndCap = arrowCap;
|
||||
|
||||
if (CenterNodeActive)
|
||||
{
|
||||
g.DrawCurve(pen, new Point[] { StartPosition, CenterPosition, EndPosition });
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawLine(pen, StartPosition, EndPosition);
|
||||
}
|
||||
}
|
||||
CustomEndCap = new AdjustableArrowCap(4, 6)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,18 +56,35 @@ public override void OnUpdate()
|
|||
|
||||
public override void OnDraw(Graphics g)
|
||||
{
|
||||
if (BorderSize > 0 && BorderColor.A > 0)
|
||||
if (Shadow)
|
||||
{
|
||||
DrawLine(g, ShadowColor, BorderSize, StartPosition.Add(ShadowDirection), EndPosition.Add(ShadowDirection), CenterPosition.Add(ShadowDirection));
|
||||
}
|
||||
|
||||
DrawLine(g, BorderColor, BorderSize, StartPosition, EndPosition, CenterPosition);
|
||||
}
|
||||
|
||||
protected virtual void DrawLine(Graphics g, Color borderColor, int borderSize, Point startPosition, Point endPosition, Point centerPosition)
|
||||
{
|
||||
if (borderSize > 0 && borderColor.A > 0)
|
||||
{
|
||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
||||
if (BorderSize.IsEvenNumber())
|
||||
if (borderSize.IsEvenNumber())
|
||||
{
|
||||
g.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
}
|
||||
|
||||
using (Pen pen = new Pen(BorderColor, BorderSize))
|
||||
using (Pen pen = CreatePen(borderColor, borderSize))
|
||||
{
|
||||
DrawLine(g, pen);
|
||||
if (CenterNodeActive)
|
||||
{
|
||||
g.DrawCurve(pen, new Point[] { startPosition, centerPosition, endPosition });
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawLine(pen, startPosition, endPosition);
|
||||
}
|
||||
}
|
||||
|
||||
g.SmoothingMode = SmoothingMode.None;
|
||||
|
@ -75,19 +92,13 @@ public override void OnDraw(Graphics g)
|
|||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawLine(Graphics g, Pen pen)
|
||||
protected virtual Pen CreatePen(Color borderColor, int borderSize)
|
||||
{
|
||||
pen.StartCap = LineCap.Round;
|
||||
pen.EndCap = LineCap.Round;
|
||||
|
||||
if (CenterNodeActive)
|
||||
return new Pen(borderColor, borderSize)
|
||||
{
|
||||
g.DrawCurve(pen, new Point[] { StartPosition, CenterPosition, EndPosition });
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawLine(pen, StartPosition, EndPosition);
|
||||
}
|
||||
StartCap = LineCap.Round,
|
||||
EndCap = LineCap.Round
|
||||
};
|
||||
}
|
||||
|
||||
public override void Move(int x, int y)
|
||||
|
|
Loading…
Reference in a new issue