Class Brush
Namespace: Aspose.Imaging
Assembly: Aspose.Imaging.dll (25.2.0)
คลาสแปรงพื้นฐาน
[JsonObject(MemberSerialization.OptIn)]
public abstract class Brush : DisposableObject, IDisposable
การสืบทอด
object ← DisposableObject ← Brush
ที่สืบทอด
HatchBrush, SolidBrush, TransformBrush
การใช้งาน
สมาชิกที่สืบทอด
DisposableObject.Dispose(), DisposableObject.ReleaseManagedResources(), DisposableObject.ReleaseUnmanagedResources(), DisposableObject.VerifyNotDisposed(), DisposableObject.Disposed, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
ตัวสร้าง
Brush()
protected Brush()
คุณสมบัติ
Opacity
รับหรือกำหนดความทึบของแปรง ค่าอยู่ระหว่าง 0 ถึง 1 ค่า 0 หมายถึงแปรงมองเห็นได้เต็มที่ ค่า 1 หมายถึงแปรงทึบสนิท
public float Opacity { get; set; }
ค่าของคุณสมบัติ
ตัวอย่าง
ตัวอย่างนี้ใช้คลาส Graphics เพื่อสร้างรูปทรงพื้นฐานบนพื้นผิวภาพ เพื่อแสดงการทำงาน ตัวอย่างนี้สร้างภาพใหม่ในรูปแบบ PNG และวาดรูปทรงพื้นฐานบนพื้นผิวภาพโดยใช้วิธีการ Draw ที่เปิดเผยโดยคลาส Graphics```csharp [C#]
//สร้างอินสแตนซ์ของ FileStream
using (System.IO.FileStream stream = new System.IO.FileStream(@"C:\temp\output.png", System.IO.FileMode.Create))
{
//สร้างอินสแตนซ์ของ PngOptions และกำหนดคุณสมบัติต่างๆ
Aspose.Imaging.ImageOptions.PngOptions pngOptions = new Aspose.Imaging.ImageOptions.PngOptions();
//กำหนดแหล่งที่มาสำหรับ PngOptions
pngOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);
//สร้างอินสแตนซ์ของภาพ
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(pngOptions, 500, 500))
{
//สร้างและเริ่มต้นอินสแตนซ์ของคลาส Graphics
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
//ล้างพื้นผิวของ Graphics
graphics.Clear(Aspose.Imaging.Color.Wheat);
//วาด Arc โดยกำหนดออบเจ็กต์ Pen ที่มีสีดำ,
//Rectangle ที่ล้อมรอบ Arc, มุมเริ่มต้นและมุมการกวาด
graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 2), new Aspose.Imaging.Rectangle(200, 200, 100, 200), 0, 300);
//วาด Bezier โดยกำหนดออบเจ็กต์ Pen ที่มีสีน้ำเงินและจุดพิกัด
graphics.DrawBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Point(250, 100), new Aspose.Imaging.Point(300, 30), new Aspose.Imaging.Point(450, 100), new Aspose.Imaging.Point(235, 25));
//วาด Curve โดยกำหนดออบเจ็กต์ Pen ที่มีสีเขียวและอาร์เรย์ของจุด
graphics.DrawCurve(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new[] { new Aspose.Imaging.Point(100, 200), new Aspose.Imaging.Point(100, 350), new Aspose.Imaging.Point(200, 450) });
//วาด Ellipse โดยใช้ Pen object และ Rectangle ที่ล้อมรอบ
graphics.DrawEllipse(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Yellow, 2), new Aspose.Imaging.Rectangle(300, 300, 100, 100));
//วาด Line
graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Violet, 2), new Aspose.Imaging.Point(100, 100), new Aspose.Imaging.Point(200, 200));
//วาด Pie segment
graphics.DrawPie(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Silver, 2), new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(200, 20), new Aspose.Imaging.Size(200, 200)), 0, 45);
//วาด Polygon โดยกำหนดออบเจ็กต์ Pen ที่มีสีแดงและอาร์เรย์ของจุด
graphics.DrawPolygon(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2), new[] { new Aspose.Imaging.Point(20, 100), new Aspose.Imaging.Point(20, 200), new Aspose.Imaging.Point(220, 20) });
//วาด Rectangle
graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 2), new Aspose.Imaging.Rectangle(new Aspose.Imaging.Point(250, 250), new Aspose.Imaging.Size(100, 100)));
//สร้างออบเจ็กต์ SolidBrush และกำหนดคุณสมบัติต่างๆ
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush();
brush.Color = Color.Purple;
brush.Opacity = 100;
//วาด String โดยใช้ SolidBrush object และ Font ที่จุดเฉพาะ
graphics.DrawString("ภาพนี้ถูกสร้างโดย Aspose.Imaging API", new Aspose.Imaging.Font("Times New Roman", 16), brush, new Aspose.Imaging.PointF(50, 400));
//บันทึกการเปลี่ยนแปลงทั้งหมด
image.Save();
}
}
## วิธีการ
### <a id="Aspose_Imaging_Brush_DeepClone"></a> DeepClone\(\)
สร้างการโคลนลึกใหม่ของ Aspose.Imaging.Brush ปัจจุบัน
```csharp
public virtual Brush DeepClone()
คืนค่า
Aspose.Imaging.Brush ใหม่ซึ่งเป็นการโคลนลึกของอินสแตนซ์ Aspose.Imaging.Brush นี้
Equals(object)
ตรวจสอบว่าคุณวัตถุมีค่าเท่ากันหรือไม่
public override bool Equals(object obj)
พารามิเตอร์
obj
object
วัตถุอื่น
คืนค่า
ผลลัพธ์ของการเปรียบเทียบความเท่าเทียมกัน
Equals(Brush)
ตรวจสอบว่าคุณวัตถุมีค่าเท่ากันหรือไม่
protected bool Equals(Brush other)
พารามิเตอร์
other
Brush
วัตถุอื่น
คืนค่า
ผลลัพธ์ของการเปรียบเทียบความเท่าเทียมกัน
GetHashCode()
รับรหัสแฮชของวัตถุปัจจุบัน
public override int GetHashCode()
คืนค่า
รหัสแฮช