mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 14:11:38 +12:00
Added gradient support to text shadow
This commit is contained in:
parent
fc4087049c
commit
736968bc4d
|
@ -92,11 +92,17 @@ public Font Font
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
public bool DrawTextShadow { get; set; }
|
public bool DrawTextShadow { get; set; }
|
||||||
|
|
||||||
|
[DefaultValue(typeof(Point), "0, 5")]
|
||||||
|
public Point TextShadowOffset { get; set; }
|
||||||
|
|
||||||
[DefaultValue(typeof(Color), "125, 0, 0, 0"), Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
|
[DefaultValue(typeof(Color), "125, 0, 0, 0"), Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
|
||||||
public Color TextShadowColor { get; set; }
|
public Color TextShadowColor { get; set; }
|
||||||
|
|
||||||
[DefaultValue(typeof(Point), "0, 5")]
|
[DefaultValue(false)]
|
||||||
public Point TextShadowOffset { get; set; }
|
public bool TextShadowUseGradient { get; set; }
|
||||||
|
|
||||||
|
[Editor(typeof(GradientEditor), typeof(UITypeEditor))]
|
||||||
|
public GradientInfo TextShadowGradient { get; set; }
|
||||||
|
|
||||||
public DrawTextEx()
|
public DrawTextEx()
|
||||||
{
|
{
|
||||||
|
@ -104,9 +110,10 @@ public DrawTextEx()
|
||||||
|
|
||||||
TextGradient = new GradientInfo();
|
TextGradient = new GradientInfo();
|
||||||
AddDefaultGradient(TextGradient);
|
AddDefaultGradient(TextGradient);
|
||||||
|
|
||||||
TextOutlineGradient = new GradientInfo();
|
TextOutlineGradient = new GradientInfo();
|
||||||
AddDefaultGradient(TextOutlineGradient);
|
AddDefaultGradient(TextOutlineGradient);
|
||||||
|
TextShadowGradient = new GradientInfo();
|
||||||
|
AddDefaultGradient(TextShadowGradient);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddDefaultGradient(GradientInfo gradientInfo)
|
private void AddDefaultGradient(GradientInfo gradientInfo)
|
||||||
|
@ -183,7 +190,7 @@ public override Bitmap Apply(Bitmap bmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw text shadow
|
// Draw text shadow
|
||||||
if (DrawTextShadow && TextShadowColor.A > 0)
|
if (DrawTextShadow && ((!TextShadowUseGradient && TextShadowColor.A > 0) || (TextShadowUseGradient && TextShadowGradient.IsVisible)))
|
||||||
{
|
{
|
||||||
using (Matrix matrix = new Matrix())
|
using (Matrix matrix = new Matrix())
|
||||||
{
|
{
|
||||||
|
@ -192,16 +199,39 @@ public override Bitmap Apply(Bitmap bmp)
|
||||||
|
|
||||||
if (DrawTextOutline && TextOutlineSize > 0)
|
if (DrawTextOutline && TextOutlineSize > 0)
|
||||||
{
|
{
|
||||||
using (Pen textShadowPen = new Pen(TextShadowColor, TextOutlineSize) { LineJoin = LineJoin.Round })
|
if (TextShadowUseGradient)
|
||||||
{
|
{
|
||||||
g.DrawPath(textShadowPen, gp);
|
using (LinearGradientBrush textShadowBrush = TextShadowGradient.GetGradientBrush(
|
||||||
|
Rectangle.Round(textRectangle).Offset(TextOutlineSize + 1).LocationOffset(TextShadowOffset)))
|
||||||
|
using (Pen textShadowPen = new Pen(textShadowBrush, TextOutlineSize) { LineJoin = LineJoin.Round })
|
||||||
|
{
|
||||||
|
g.DrawPath(textShadowPen, gp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (Pen textShadowPen = new Pen(TextShadowColor, TextOutlineSize) { LineJoin = LineJoin.Round })
|
||||||
|
{
|
||||||
|
g.DrawPath(textShadowPen, gp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (Brush textShadowBrush = new SolidBrush(TextShadowColor))
|
if (TextShadowUseGradient)
|
||||||
{
|
{
|
||||||
g.FillPath(textShadowBrush, gp);
|
using (Brush textShadowBrush = TextShadowGradient.GetGradientBrush(
|
||||||
|
Rectangle.Round(textRectangle).Offset(1).LocationOffset(TextShadowOffset)))
|
||||||
|
{
|
||||||
|
g.FillPath(textShadowBrush, gp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (Brush textShadowBrush = new SolidBrush(TextShadowColor))
|
||||||
|
{
|
||||||
|
g.FillPath(textShadowBrush, gp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue