0

在此处输入图像描述

我正在尝试制作像图片一样的画笔。我应该怎么办?

在 System.Drawing.Color 中,它是按如下方式完成的。

C# WinForm

Rectangle drawRc = new Rectangle(x1, y1, x2 - x1, y2 - y1);
Color[] colors = { Color.FromArgb(255, 0, 0, 0) };
GraphicsPath path = new GraphicsPath();
path.AddRectangle(drawRc);
PathGradientBrush pdb = new PathGradientBrush(path)
{
    CenterPoint = new PointF(x2, y2),
    CenterColor = patCol,
    SurroundColors = colors
};

g.FillRectangle(pdb, drawRc);
pdb.Dispose();

wpf

double StartX = 1.00d, StartY = 1.00d;
var list = new List<GradientStop>();
list.Add(new GradientStop(Colors.Red, 0));
list.Add(new GradientStop(Colors.Black, 1));
                        
var gradient = new GradientStopCollection(list);
var brush = new RadialGradientBrush(gradients) {
    MappingMode = BrushMappingMode.RelativeToBoundingBox,
    GradientOrigin = new Point(StartX, StartY),
    RadiusX = 0.7,
    RadiusY = 0.7,
    Center = new Point(0.7,0.7)
};
4

0 回答 0