Class Pen

Class Pen

名称: Aspose.Imaging 收藏: Aspose.Imaging.dll (25.4.0)

定义用于绘制线条、曲线和数字的对象。

public class Pen : TransparencySupporter

Inheritance

object TransparencySupporter Pen

继承人

TransparencySupporter.Equals(object) , TransparencySupporter.GetHashCode() , TransparencySupporter.Equals(TransparencySupporter) , TransparencySupporter.Opacity , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

此示例显示创建和使用笔对象 示例创建一个新的图像,并在图像表面绘制直角。

//Create an instance of BmpOptions and set its various properties
                                                                                                                                       Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                                                                                                                                       bmpOptions.BitsPerPixel = 24;

                                                                                                                                       //Create an instance of FileCreateSource and assign it as Source for the instance of BmpOptions
                                                                                                                                       //Second Boolean parameter determines if the file to be created IsTemporal or not
                                                                                                                                       bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\sample.bmp", false);

                                                                                                                                       //Create an instance of Image at specified Path
                                                                                                                                       using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
                                                                                                                                       {
                                                                                                                                           //Create an instance of Graphics and initialize it with Image object
                                                                                                                                           Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

                                                                                                                                           //Clear the Graphics sutface with White Color
                                                                                                                                           graphics.Clear(Aspose.Imaging.Color.White);

                                                                                                                                           //Create an instance of Pen with color Red and width 5
                                                                                                                                           Aspose.Imaging.Pen pen = new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 5f);

                                                                                                                                           //Create an instance of HatchBrush and set its properties
                                                                                                                                           Aspose.Imaging.Brushes.HatchBrush brush = new Aspose.Imaging.Brushes.HatchBrush();
                                                                                                                                           brush.BackgroundColor = Aspose.Imaging.Color.Wheat;
                                                                                                                                           brush.ForegroundColor = Aspose.Imaging.Color.Red;

                                                                                                                                           //Create an instance of Pen
                                                                                                                                           //initialize it with HatchBrush object and width
                                                                                                                                           Aspose.Imaging.Pen brusedpen = new Pen(brush, 5);

                                                                                                                                           //Draw Rectangles by specifying Pen object
                                                                                                                                           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))
                                                                                                                                           });

                                                                                                                                           //Draw Rectangles by specifying Pen object
                                                                                                                                           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))
                                                                                                                                           });

                                                                                                                                           // save all changes.
                                                                                                                                           image.Save();
                                                                                                                                       }

Constructors

Pen(Color)

以指定的颜色启动 Aspose.Imaging.Pen 类的新例子。

public Pen(Color color)

Parameters

color Color

一个 Aspose.Imaging.Pen.Color 结构,表明这个 Aspose.Imaging.Pen 的颜色。

Pen(颜色,浮动)

启动一个新的例子的Aspose.Imaging.Pen类与指定的Aspose.Imaging.Pen.Color和Aspose.Imaging.Pen.Width属性。

public Pen(Color color, float width)

Parameters

color Color

一个 Aspose.Imaging.Pen.Color 结构,表明这个 Aspose.Imaging.Pen 的颜色。

width float

一个值表明这个 Aspose.Imaging.Pen 的宽度。

Examples

此示例显示创建和使用笔对象 示例创建一个新的图像,并在图像表面绘制直角。

//Create an instance of BmpOptions and set its various properties
                                                                                                                                       Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                                                                                                                                       bmpOptions.BitsPerPixel = 24;

                                                                                                                                       //Create an instance of FileCreateSource and assign it as Source for the instance of BmpOptions
                                                                                                                                       //Second Boolean parameter determines if the file to be created IsTemporal or not
                                                                                                                                       bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\sample.bmp", false);

                                                                                                                                       //Create an instance of Image at specified Path
                                                                                                                                       using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
                                                                                                                                       {
                                                                                                                                           //Create an instance of Graphics and initialize it with Image object
                                                                                                                                           Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

                                                                                                                                           //Clear the Graphics sutface with White Color
                                                                                                                                           graphics.Clear(Aspose.Imaging.Color.White);

                                                                                                                                           //Create an instance of Pen with color Red and width 5
                                                                                                                                           Aspose.Imaging.Pen pen = new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 5f);

                                                                                                                                           //Create an instance of HatchBrush and set its properties
                                                                                                                                           Aspose.Imaging.Brushes.HatchBrush brush = new Aspose.Imaging.Brushes.HatchBrush();
                                                                                                                                           brush.BackgroundColor = Aspose.Imaging.Color.Wheat;
                                                                                                                                           brush.ForegroundColor = Aspose.Imaging.Color.Red;

                                                                                                                                           //Create an instance of Pen
                                                                                                                                           //initialize it with HatchBrush object and width
                                                                                                                                           Aspose.Imaging.Pen brusedpen = new Pen(brush, 5);

                                                                                                                                           //Draw Rectangles by specifying Pen object
                                                                                                                                           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))
                                                                                                                                           });

                                                                                                                                           //Draw Rectangles by specifying Pen object
                                                                                                                                           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))
                                                                                                                                           });

                                                                                                                                           // save all changes.
                                                                                                                                           image.Save();
                                                                                                                                       }

Pen(Brush)

启动 Aspose.Imaging.Pen 类的新例子,并使用指定的 Aspose.Imaging.Pen.Brush。

public Pen(Brush brush)

Parameters

brush Brush

一个 Aspose.Imaging.Pen.Brush 决定这个 Aspose.Imaging.Pen 的填充属性。

Exceptions

ArgumentNullException

brush’ is null.

Pen(毛巾,浮动)

启动一个新的例子的Aspose.Imaging.Pen类与指定的Aspose.Imaging.Pen.Brush和Aspose.Imaging.Pen.Width。

[JsonConstructor]
public Pen(Brush brush, float width)

Parameters

brush Brush

一个 Aspose.Imaging.Pen.Brush 决定这个 Aspose.Imaging.Pen 的特点。

width float

新的 Aspose.Imaging.Pen 的宽度。

Exceptions

ArgumentNullException

brush’ is null.

Properties

Alignment

得到或设置这个 Aspose.Imaging.Pen 的匹配。

public PenAlignment Alignment { get; set; }

财产价值

PenAlignment

Exceptions

ArgumentException

Aspose.Imaging.Pen.Alignment 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

Brush

获取或设置 Aspose.Imaging.Pen.Brush 以确定这个 Aspose.Imaging.Pen 的属性。

public Brush Brush { get; set; }

财产价值

Brush

Exceptions

ArgumentException

Aspose.Imaging.Pen.Brush 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

Color

得到或设置这个 Aspose.Imaging.Pen 的颜色。

public Color Color { get; set; }

财产价值

Color

Exceptions

ArgumentException

Aspose.Imaging.Pen.Color 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

CompoundArray

收到或设置一系列值,指定一个合金铅笔. 合金铅笔引导一个由平行线和空间组成的合金线。

public float[] CompoundArray { get; set; }

财产价值

float ( )

Exceptions

ArgumentException

Aspose.Imaging.Pen.CompoundArray 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

CustomEndCap

接收或设置一个自定义的封面,用于使用在与此 Aspose.Imaging.Pen 绘制的线条的尽头。

public CustomLineCap CustomEndCap { get; set; }

财产价值

CustomLineCap

Exceptions

ArgumentException

Aspose.Imaging.Pen.CustomEndCap 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

CustomStartCap

接收或设置一个自定义的封面,以便在与此 Aspose.Imaging.Pen 绘制的线条的开始使用。

public CustomLineCap CustomStartCap { get; set; }

财产价值

CustomLineCap

Exceptions

ArgumentException

Aspose.Imaging.Pen.CustomStartCap 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

DashCap

接收或设置使用的帽子风格在底部的板块,形成板块线与这个 Aspose.Imaging.Pen 拖动。

public DashCap DashCap { get; set; }

财产价值

DashCap

Exceptions

ArgumentException

Aspose.Imaging.Pen.DashCap 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

DashOffset

接收或设置从一行开始到一行模型的开始的距离。

public float DashOffset { get; set; }

财产价值

float

DashPattern

接收或设置一系列自定义的板块和空间。

public float[] DashPattern { get; set; }

财产价值

float ( )

Exceptions

ArgumentException

Aspose.Imaging.Pen.DashPattern 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

DashStyle

获取或设置使用的风格,以此 Aspose.Imaging.Pen 引导的粘贴线。

public DashStyle DashStyle { get; set; }

财产价值

DashStyle

Exceptions

ArgumentException

Aspose.Imaging.Pen.DashStyle 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

EndCap

获取或设置使用的字符串风格在线条的尽头与这个 Aspose.Imaging.Pen。

public LineCap EndCap { get; set; }

财产价值

LineCap

Exceptions

ArgumentException

Aspose.Imaging.Pen.EndCap 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

LineJoin

接收或设置连接风格的两条连续线的结尾,用这个 Aspose.Imaging.Pen。

public LineJoin LineJoin { get; set; }

财产价值

LineJoin

Exceptions

ArgumentException

Aspose.Imaging.Pen.LineJoin 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

MiterLimit

接收或设置粘贴的厚度限制在一个测量的角。

public float MiterLimit { get; set; }

财产价值

float

Exceptions

ArgumentException

Aspose.Imaging.Pen.MiterLimit 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

PenType

得到与此 Aspose.Imaging.Pen 绘制的线条的风格。

[JsonIgnore]
public PenType PenType { get; }

财产价值

PenType

StartCap

获取或设置使用的字符串风格在开始的线条引用这个 Aspose.Imaging.Pen。

public LineCap StartCap { get; set; }

财产价值

LineCap

Exceptions

ArgumentException

Aspose.Imaging.Pen.StartCap 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

Transform

获取或设置此 Aspose.Imaging.Pen 的地质转型副本。

public Matrix Transform { get; set; }

财产价值

Matrix

Exceptions

ArgumentException

Aspose.Imaging.Pen.Transform 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

Width

获取或设置这个 Aspose.Imaging.Pen 的宽度,在用于绘画的图形对象的单位。

public float Width { get; set; }

财产价值

float

Exceptions

ArgumentException

Aspose.Imaging.Pen.Width 属性设置在一个不可变的 Aspose.Imaging.Pen,如由 Aspose.Imaging.Pen 类返回的属性。

Methods

Equals(对象)

检查对象是否平等。

public override bool Equals(object obj)

Parameters

obj object

其它对象。

Returns

bool

平等比较结果。

Equals(Pen)

检查对象是否平等。

protected bool Equals(Pen other)

Parameters

other Pen

其它对象。

Returns

bool

平等比较结果。

GetHashCode()

获取当前对象的哈希代码。

public override int GetHashCode()

Returns

int

哈希代码。

MultiplyTransform(Matrix)

通过指定的 Aspose.Imaging.Matrix 增加这个 Aspose.Imaging.Pen 的转换矩阵。

public void MultiplyTransform(Matrix matrix)

Parameters

matrix Matrix

Aspose.Imaging.Matrix 对象,以多元化转型矩阵。

MultiplyTransform(马特里克,马特里克)

通过指定的 Aspose.Imaging.Matrix 在指定的顺序中增加这个 Aspose.Imaging.Pen 的转换矩阵。

public void MultiplyTransform(Matrix matrix, MatrixOrder order)

Parameters

matrix Matrix

Aspose.Imaging.Matrix 用它来多元化转型矩阵。

order MatrixOrder

命令执行复制操作。

ResetTransform()

重新设置这个 Aspose.Imaging.Pen 的地质转型矩阵到身份。

public void ResetTransform()

RotateTransform(航海)

旋转本地地数学转换为指定的角度,这种方法将旋转转向转换。

public void RotateTransform(float angle)

Parameters

angle float

旋转的角度。

RotateTransform(航海,MatrixOrder)

旋转本地地数学转换在指定的顺序中指定的角度。

public void RotateTransform(float angle, MatrixOrder order)

Parameters

angle float

旋转的角度。

order MatrixOrder

一个 Aspose.Imaging.MatrixOrder 指定是否附加或附加旋转矩阵。

ScaleTransform(航海,航海)

按指定的因素衡量本地地地质转型,这种方法将扩展矩阵与转型有关。

public void ScaleTransform(float sx, float sy)

Parameters

sx float

要衡量转型在X轴方向的因素。

sy float

要因在 y-axis 方向进行转型。

ScaleTransform(航海,航海,MatrixOrder)

按指定的顺序的指定的因素衡量地理转型。

public void ScaleTransform(float sx, float sy, MatrixOrder order)

Parameters

sx float

要衡量转型在X轴方向的因素。

sy float

要因在 y-axis 方向进行转型。

order MatrixOrder

一个 Aspose.Imaging.MatrixOrder 指定是否要扩展或扩展扩展矩阵。

SetLineCap(LineCap、LineCap、DashCap)

设置由此 Aspose.Imaging.Pen 绘制的结尾线所使用的封面风格的值。

public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)

Parameters

startCap LineCap

一个 Aspose.Imaging.LineCap 代表在这个 Aspose.Imaging.Pen 引导的线条的开始使用的封面风格。

endCap LineCap

一个 Aspose.Imaging.LineCap 代表在这个 Aspose.Imaging.Pen 绘制的线条的结尾使用的封面风格。

dashCap DashCap

一个 Aspose.Imaging.LineCap 代表在开始或结束时使用的封面风格,带有这个 Aspose.Imaging.Pen。

TranslateTransform(航海,航海)

翻译本地地数学转型,根据所指定的尺寸,这种方法将翻译与转型有关。

public void TranslateTransform(float dx, float dy)

Parameters

dx float

翻译的值为x。

dy float

翻译的价值在Y。

TranslateTransform(航海,航海,MatrixOrder)

翻译本地地数学转型,根据指定的尺寸在指定的顺序。

public void TranslateTransform(float dx, float dy, MatrixOrder order)

Parameters

dx float

翻译的值为x。

dy float

翻译的价值在Y。

order MatrixOrder

命令(提交或附加)适用翻译。

 中文