mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added shadow to rectangle drawing
This commit is contained in:
parent
401f8a0c3c
commit
42fb490c4c
6 changed files with 31 additions and 17 deletions
|
@ -55,6 +55,8 @@ public static void DrawRectangleShadow(this Graphics g, Rectangle rect, Color sh
|
||||||
{
|
{
|
||||||
int currentAlpha = (int)MathHelpers.Lerp(shadowMaxAlpha, shadowMinAlpha, (float)i / (shadowDepth - 1));
|
int currentAlpha = (int)MathHelpers.Lerp(shadowMaxAlpha, shadowMinAlpha, (float)i / (shadowDepth - 1));
|
||||||
|
|
||||||
|
if (currentAlpha > 0)
|
||||||
|
{
|
||||||
using (Pen pen = new Pen(Color.FromArgb(currentAlpha, shadowColor)))
|
using (Pen pen = new Pen(Color.FromArgb(currentAlpha, shadowColor)))
|
||||||
{
|
{
|
||||||
Rectangle shadowRect = new Rectangle(rect.X + -shadowDirection.Left * i, rect.Y + -shadowDirection.Top * i,
|
Rectangle shadowRect = new Rectangle(rect.X + -shadowDirection.Left * i, rect.Y + -shadowDirection.Top * i,
|
||||||
|
@ -64,6 +66,12 @@ public static void DrawRectangleShadow(this Graphics g, Rectangle rect, Color sh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawRoundedRectangle(this Graphics g, Pen pen, Rectangle rect, float radius)
|
||||||
|
{
|
||||||
|
g.DrawRoundedRectangle(null, pen, rect, radius);
|
||||||
|
}
|
||||||
|
|
||||||
public static void DrawRoundedRectangle(this Graphics g, Brush brush, Pen pen, Rectangle rect, float radius)
|
public static void DrawRoundedRectangle(this Graphics g, Brush brush, Pen pen, Rectangle rect, float radius)
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,6 +140,10 @@ public enum FFmpegPaletteUseDither
|
||||||
|
|
||||||
public enum ShapeType
|
public enum ShapeType
|
||||||
{
|
{
|
||||||
|
[Description("Drawing: Rectangle")]
|
||||||
|
DrawingRectangle,
|
||||||
|
[Description("Drawing: Rounded rectangle")]
|
||||||
|
DrawingRoundedRectangle,
|
||||||
[Description("Region: Rectangle")]
|
[Description("Region: Rectangle")]
|
||||||
RegionRectangle,
|
RegionRectangle,
|
||||||
[Description("Region: Rounded rectangle")]
|
[Description("Region: Rounded rectangle")]
|
||||||
|
@ -149,11 +153,7 @@ public enum ShapeType
|
||||||
[Description("Region: Triangle")]
|
[Description("Region: Triangle")]
|
||||||
RegionTriangle,
|
RegionTriangle,
|
||||||
[Description("Region: Diamond")]
|
[Description("Region: Diamond")]
|
||||||
RegionDiamond,
|
RegionDiamond
|
||||||
[Description("Drawing: Rectangle")]
|
|
||||||
DrawingRectangle,
|
|
||||||
[Description("Drawing: Rounded rectangle")]
|
|
||||||
DrawingRoundedRectangle
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RegionAnnotateMode
|
public enum RegionAnnotateMode
|
||||||
|
|
|
@ -112,7 +112,7 @@ public bool IsCurrentShapeTypeRegion
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color BorderColor { get; set; } = Color.Red;
|
public Color BorderColor { get; set; } = Color.Red;
|
||||||
public int BorderSize { get; set; } = 2;
|
public int BorderSize { get; set; } = 1;
|
||||||
public Color FillColor { get; set; } = Color.Transparent;
|
public Color FillColor { get; set; } = Color.Transparent;
|
||||||
|
|
||||||
public float RoundedRectangleRadius { get; set; } = 25;
|
public float RoundedRectangleRadius { get; set; } = 25;
|
||||||
|
|
|
@ -35,9 +35,9 @@ namespace ShareX.ScreenCaptureLib
|
||||||
{
|
{
|
||||||
public abstract class BaseDrawingShape : BaseShape
|
public abstract class BaseDrawingShape : BaseShape
|
||||||
{
|
{
|
||||||
public Color BorderColor { get; set; } = Color.Red;
|
public Color BorderColor { get; set; }
|
||||||
public Color FillColor { get; set; } = Color.Transparent;
|
public Color FillColor { get; set; }
|
||||||
public int BorderSize { get; set; } = 2;
|
public int BorderSize { get; set; }
|
||||||
|
|
||||||
public abstract void Draw(Graphics g);
|
public abstract void Draw(Graphics g);
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,10 @@ You should have received a copy of the GNU General Public License
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace ShareX.ScreenCaptureLib
|
namespace ShareX.ScreenCaptureLib
|
||||||
{
|
{
|
||||||
|
@ -46,11 +48,15 @@ public override void Draw(Graphics g)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BorderColor != Color.Transparent)
|
if (BorderColor != Color.Transparent && BorderSize > 0)
|
||||||
{
|
{
|
||||||
using (Pen pen = new Pen(BorderColor, BorderSize))
|
Rectangle rect = Rectangle.Offset(BorderSize - 1);
|
||||||
|
|
||||||
|
g.DrawRectangleShadow(rect.Offset(1), Color.FromArgb(150, 150, 150), 3, 100, 10, new Padding(1));
|
||||||
|
|
||||||
|
using (Pen pen = new Pen(BorderColor, BorderSize) { Alignment = PenAlignment.Inset })
|
||||||
{
|
{
|
||||||
g.DrawRectangleProper(pen, Rectangle);
|
g.DrawRectangleProper(pen, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public override void Draw(Graphics g)
|
||||||
brush = new SolidBrush(FillColor);
|
brush = new SolidBrush(FillColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BorderColor != Color.Transparent)
|
if (BorderColor != Color.Transparent && BorderSize > 0)
|
||||||
{
|
{
|
||||||
pen = new Pen(BorderColor, BorderSize);
|
pen = new Pen(BorderColor, BorderSize);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue