Class HatchBrush
Namespace: Aspose.Imaging.Brushes
Assembly: Aspose.Imaging.dll (25.2.0)
กำหนดแปรงสี่เหลี่ยมที่มีสไตล์แฮตช์ สีพื้นหน้า และสีพื้นหลัง คลาสนี้ไม่สามารถสืบทอดได้
[JsonObject(MemberSerialization.OptIn)]
public sealed class HatchBrush : Brush, IDisposable
การสืบทอด
object ← DisposableObject ← Brush ← HatchBrush
การนำไปใช้
สมาชิกที่สืบทอด
Brush.DeepClone(), Brush.Equals(object), Brush.GetHashCode(), Brush.Opacity, DisposableObject.Dispose(), DisposableObject.Disposed, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
ตัวอย่าง
ตัวอย่างนี้แสดงการสร้างและการใช้งานวัตถุ Pen ตัวอย่างจะสร้างภาพใหม่และวาดสี่เหลี่ยมบนพื้นผิวของภาพ```csharp [C#]
//สร้างอินสแตนซ์ของ BmpOptions และตั้งค่าคุณสมบัติต่างๆ
Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
bmpOptions.BitsPerPixel = 24;
//สร้างอินสแตนซ์ของ FileCreateSource และกำหนดให้เป็นแหล่งที่มาสำหรับอินสแตนซ์ของ BmpOptions
//พารามิเตอร์ Boolean ที่สองกำหนดว่าฟายล์ที่จะสร้างเป็นชั่วคราวหรือไม่
bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\sample.bmp", false);
//สร้างอินสแตนซ์ของภาพที่เส้นทางที่กำหนด
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
{
//สร้างอินสแตนซ์ของ Graphics และเริ่มต้นด้วยวัตถุ Image
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
//ล้างพื้นผิว Graphics ด้วยสีขาว
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();
}
## ตัวสร้าง
### <a id="Aspose_Imaging_Brushes_HatchBrush__ctor"></a> HatchBrush\(\)
```csharp
public HatchBrush()
คุณสมบัติ
BackgroundColor
รับหรือกำหนดสีของช่องว่างระหว่างเส้นแฮตช์
public Color BackgroundColor { get; set; }
ค่าคุณสมบัติ
ตัวอย่าง
ตัวอย่างนี้แสดงการสร้างและการใช้งานวัตถุ Pen ตัวอย่างจะสร้างภาพใหม่และวาดสี่เหลี่ยมบนพื้นผิวของภาพ```csharp [C#]
//สร้างอินสแตนซ์ของ BmpOptions และตั้งค่าคุณสมบัติต่างๆ
Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
bmpOptions.BitsPerPixel = 24;
//สร้างอินสแตนซ์ของ FileCreateSource และกำหนดให้เป็นแหล่งที่มาสำหรับอินสแตนซ์ของ BmpOptions
//พารามิเตอร์ Boolean ที่สองกำหนดว่าฟายล์ที่จะสร้างเป็นชั่วคราวหรือไม่
bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\sample.bmp", false);
//สร้างอินสแตนซ์ของภาพที่เส้นทางที่กำหนด
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
{
//สร้างอินสแตนซ์ของ Graphics และเริ่มต้นด้วยวัตถุ Image
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
//ล้างพื้นผิว Graphics ด้วยสีขาว
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();
}
### <a id="Aspose_Imaging_Brushes_HatchBrush_ForegroundColor"></a> ForegroundColor
รับหรือกำหนดสีของเส้นแฮตช์
```csharp
public Color ForegroundColor { get; set; }
ค่าคุณสมบัติ
ตัวอย่าง
ตัวอย่างนี้แสดงการสร้างและการใช้งานวัตถุ Pen ตัวอย่างจะสร้างภาพใหม่และวาดสี่เหลี่ยมบนพื้นผิวของภาพ```csharp [C#]
//สร้างอินสแตนซ์ของ BmpOptions และตั้งค่าคุณสมบัติต่างๆ
Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
bmpOptions.BitsPerPixel = 24;
//สร้างอินสแตนซ์ของ FileCreateSource และกำหนดให้เป็นแหล่งที่มาสำหรับอินสแตนซ์ของ BmpOptions
//พารามิเตอร์ Boolean ที่สองกำหนดว่าฟายล์ที่จะสร้างเป็นชั่วคราวหรือไม่
bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\sample.bmp", false);
//สร้างอินสแตนซ์ของภาพที่เส้นทางที่กำหนด
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
{
//สร้างอินสแตนซ์ของ Graphics และเริ่มต้นด้วยวัตถุ Image
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
//ล้างพื้นผิว Graphics ด้วยสีขาว
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();
}
### <a id="Aspose_Imaging_Brushes_HatchBrush_HatchStyle"></a> HatchStyle
รับหรือกำหนดสไตล์แฮตช์ของแปรงนี้
```csharp
public HatchStyle HatchStyle { get; set; }