Class HatchBrush
Namespace: Aspose.Imaging.Brushes
Assembly: Aspose.Imaging.dll (25.2.0)
Definiuje prostokątny pędzel o stylu szrafu, kolorze pierwszoplanowym i kolorze tła. Klasa ta nie może być dziedziczona.
[JsonObject(MemberSerialization.OptIn)]
public sealed class HatchBrush : Brush, IDisposable
Dziedziczenie
object ← DisposableObject ← Brush ← HatchBrush
Implementuje
Członkowie dziedziczeni
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()
Przykłady
Ten przykład pokazuje tworzenie i użycie obiektów Pen. Przykład tworzy nowy obraz i rysuje prostokąty na powierzchni obrazu.```csharp [C#]
//Utwórz instancję BmpOptions i ustaw jej różne właściwości
Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
bmpOptions.BitsPerPixel = 24;
//Utwórz instancję FileCreateSource i przypisz ją jako źródło dla instancji BmpOptions
//Drugi parametr Boolean określa, czy plik ma być tworzony jako tymczasowy
bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\sample.bmp", false);
//Utwórz instancję obrazu w określonej ścieżce
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
{
//Utwórz instancję Graphics i zainicjalizuj ją obiektem Image
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
//Wyczyść powierzchnię Graphics białym kolorem
graphics.Clear(Aspose.Imaging.Color.White);
//Utwórz instancję Pen o kolorze czerwonym i szerokości 5
Aspose.Imaging.Pen pen = new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 5f);
//Utwórz instancję HatchBrush i ustaw jej właściwości
Aspose.Imaging.Brushes.HatchBrush brush = new Aspose.Imaging.Brushes.HatchBrush();
brush.BackgroundColor = Aspose.Imaging.Color.Wheat;
brush.ForegroundColor = Aspose.Imaging.Color.Red;
//Utwórz instancję Pen
//zainicjalizuj ją obiektem HatchBrush i szerokością
Aspose.Imaging.Pen brusedpen = new Pen(brush, 5);
//Rysuj prostokąty, określając obiekt 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))
});
//Rysuj prostokąty, określając obiekt 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))
});
// zapisz wszystkie zmiany.
image.Save();
}
## Konstruktory
### <a id="Aspose_Imaging_Brushes_HatchBrush__ctor"></a> HatchBrush\(\)
```csharp
public HatchBrush()
Właściwości
BackgroundColor
Pobiera lub ustawia kolor przestrzeni między liniami szrafu.
public Color BackgroundColor { get; set; }
Wartość właściwości
Przykłady
Ten przykład pokazuje tworzenie i użycie obiektów Pen. Przykład tworzy nowy obraz i rysuje prostokąty na powierzchni obrazu.```csharp [C#]
//Utwórz instancję BmpOptions i ustaw jej różne właściwości
Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
bmpOptions.BitsPerPixel = 24;
//Utwórz instancję FileCreateSource i przypisz ją jako źródło dla instancji BmpOptions
//Drugi parametr Boolean określa, czy plik ma być tworzony jako tymczasowy
bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\sample.bmp", false);
//Utwórz instancję obrazu w określonej ścieżce
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
{
//Utwórz instancję Graphics i zainicjalizuj ją obiektem Image
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
//Wyczyść powierzchnię Graphics białym kolorem
graphics.Clear(Aspose.Imaging.Color.White);
//Utwórz instancję Pen o kolorze czerwonym i szerokości 5
Aspose.Imaging.Pen pen = new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 5f);
//Utwórz instancję HatchBrush i ustaw jej właściwości
Aspose.Imaging.Brushes.HatchBrush brush = new Aspose.Imaging.Brushes.HatchBrush();
brush.BackgroundColor = Aspose.Imaging.Color.Wheat;
brush.ForegroundColor = Aspose.Imaging.Color.Red;
//Utwórz instancję Pen
//zainicjalizuj ją obiektem HatchBrush i szerokością
Aspose.Imaging.Pen brusedpen = new Pen(brush, 5);
//Rysuj prostokąty, określając obiekt 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))
});
//Rysuj prostokąty, określając obiekt 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))
});
// zapisz wszystkie zmiany.
image.Save();
}
### <a id="Aspose_Imaging_Brushes_HatchBrush_ForegroundColor"></a> ForegroundColor
Pobiera lub ustawia kolor linii szrafu.
```csharp
public Color ForegroundColor { get; set; }
Wartość właściwości
Przykłady
Ten przykład pokazuje tworzenie i użycie obiektów Pen. Przykład tworzy nowy obraz i rysuje prostokąty na powierzchni obrazu.```csharp [C#]
//Utwórz instancję BmpOptions i ustaw jej różne właściwości
Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
bmpOptions.BitsPerPixel = 24;
//Utwórz instancję FileCreateSource i przypisz ją jako źródło dla instancji BmpOptions
//Drugi parametr Boolean określa, czy plik ma być tworzony jako tymczasowy
bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\sample.bmp", false);
//Utwórz instancję obrazu w określonej ścieżce
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
{
//Utwórz instancję Graphics i zainicjalizuj ją obiektem Image
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
//Wyczyść powierzchnię Graphics białym kolorem
graphics.Clear(Aspose.Imaging.Color.White);
//Utwórz instancję Pen o kolorze czerwonym i szerokości 5
Aspose.Imaging.Pen pen = new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 5f);
//Utwórz instancję HatchBrush i ustaw jej właściwości
Aspose.Imaging.Brushes.HatchBrush brush = new Aspose.Imaging.Brushes.HatchBrush();
brush.BackgroundColor = Aspose.Imaging.Color.Wheat;
brush.ForegroundColor = Aspose.Imaging.Color.Red;
//Utwórz instancję Pen
//zainicjalizuj ją obiektem HatchBrush i szerokością
Aspose.Imaging.Pen brusedpen = new Pen(brush, 5);
//Rysuj prostokąty, określając obiekt 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))
});
//Rysuj prostokąty, określając obiekt 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))
});
// zapisz wszystkie zmiany.
image.Save();
}
### <a id="Aspose_Imaging_Brushes_HatchBrush_HatchStyle"></a> HatchStyle
Pobiera lub ustawia styl szrafu tego pędzla.
```csharp
public HatchStyle HatchStyle { get; set; }