Pen

Pen(Color)

初始化Pen具有指定颜色的类。

public Pen(Color color)
范围类型描述
colorColor一个Color指示此颜色的结构Pen.

也可以看看


Pen(Color, float)

初始化Pen具有指定的类ColorWidth属性.

public Pen(Color color, float width)
范围类型描述
colorColor一个Color指示此颜色的结构Pen.
widthSingle表示此宽度的值Pen.

例子

这个例子展示了 Pen 对象的创建和使用。该示例创建一个新图像并在图像表面上绘制矩形。

[C#]

//创建一个BmpOptions的实例并设置它的各种属性
Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
bmpOptions.BitsPerPixel = 24;

//创建一个 FileCreateSource 的实例并将其分配为 BmpOptions 实例的 Source
//第二个布尔参数确定要创建的文件是否为IsTemporal
bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\sample.bmp", false);

//在指定路径创建一个Image实例
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
{
    //创建一个Graphics实例并用Image对象初始化
    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

    //用白色清除图形表面
    graphics.Clear(Aspose.Imaging.Color.White);

    //创建一个Pen实例,颜色为红色,宽度为5
    Aspose.Imaging.Pen pen = new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 5f);

    //创建一个HatchBrush实例并设置它的属性
    Aspose.Imaging.Brushes.HatchBrush brush = new Aspose.Imaging.Brushes.HatchBrush();
    brush.BackgroundColor = Aspose.Imaging.Color.Wheat;
    brush.ForegroundColor = Aspose.Imaging.Color.Red;

    //创建一个Pen实例
    //用 HatchBrush 对象和宽度初始化它
    Aspose.Imaging.Pen brusedpen = new Pen(brush, 5);

    //通过指定Pen对象绘制矩形
    graphics.DrawRectangles(pen, new[]
    {
        new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(210, 210), new Aspose.Imaging.Size(100, 100)),
        new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(110, 110), new Aspose.Imaging.Size(100, 100)),
        new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(310, 310), new Aspose.Imaging.Size(100, 100))
    });

    //通过指定Pen对象绘制矩形
    graphics.DrawRectangles(brusedpen, new[]
    {
        new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(310, 110), new Aspose.Imaging.Size(100, 100)),
        new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(110, 310), new Aspose.Imaging.Size(100, 100))
    });

    // 保存所有更改。
    image.Save();
}

也可以看看


Pen(Brush)

初始化Pen具有指定的类Brush .

public Pen(Brush brush)
范围类型描述
brushBrush一个Brush决定了这个的填充属性Pen.

例外

例外(健康)状况
ArgumentNullExceptionbrush一片空白。

也可以看看


Pen(Brush, float)

初始化Pen具有指定的类BrushWidth .

public Pen(Brush brush, float width)
范围类型描述
brushBrush一个Brush这决定了它的特性Pen.
widthSingle新的宽度Pen.

例外

例外(健康)状况
ArgumentNullExceptionbrush一片空白。

也可以看看