Class Canvas
Represents a 2d drawing surface
Inheritance
System.Object
Canvas
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Azos.dll
Syntax
public sealed class Canvas : DisposableObject, IDisposable
Properties
Interpolation
Defines how pixel colors are approximated/interpolated during image resize, rotate and other operations
which distort 1:1 pixel mappings
Declaration
public InterpolationMode Interpolation { get; set; }
Property Value
OwnsAssets
Returns true when all assets (such as brushes, pens, fonts) are owned by the canvas instance and
they can not be used/persisted beyond the scope of this canvas lifecycle.
Some libraries allow to create objects and cache them for subsequent use, whereas others (e.g. Windows classic GDI)
mandate that all graphics handles belong to the particular canvas instance and get invalidated when that instance
gets releases via Dispose()
Declaration
public static bool OwnsAssets { get; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
Clear(Color)
Declaration
public void Clear(Color color)
Parameters
Type |
Name |
Description |
System.Drawing.Color |
color |
|
CreateFont(String, Single, FontStyling, MeasureUnit)
Declaration
public Canvas.Font CreateFont(string name, float size, FontStyling style, MeasureUnit unit)
Parameters
Returns
CreatePen(Color, Single, PenDashStyle)
Declaration
public Canvas.Pen CreatePen(Color color, float width, PenDashStyle style)
Parameters
Type |
Name |
Description |
System.Drawing.Color |
color |
|
System.Single |
width |
|
PenDashStyle |
style |
|
Returns
CreateSolidBrush(Color)
Declaration
public Canvas.Brush CreateSolidBrush(Color color)
Parameters
Type |
Name |
Description |
System.Drawing.Color |
color |
|
Returns
Destructor()
Declaration
protected override void Destructor()
Overrides
DrawEllipse(Canvas.Pen, Rectangle)
Declaration
public void DrawEllipse(Canvas.Pen pen, Rectangle rect)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Drawing.Rectangle |
rect |
|
DrawEllipse(Canvas.Pen, RectangleF)
Declaration
public void DrawEllipse(Canvas.Pen pen, RectangleF rect)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Drawing.RectangleF |
rect |
|
DrawEllipse(Canvas.Pen, Int32, Int32, Int32, Int32)
Declaration
public void DrawEllipse(Canvas.Pen pen, int x, int y, int w, int h)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Int32 |
x |
|
System.Int32 |
y |
|
System.Int32 |
w |
|
System.Int32 |
h |
|
DrawEllipse(Canvas.Pen, Single, Single, Single, Single)
Declaration
public void DrawEllipse(Canvas.Pen pen, float x, float y, float w, float h)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Single |
x |
|
System.Single |
y |
|
System.Single |
w |
|
System.Single |
h |
|
DrawImage(Image, Rectangle)
Declaration
public void DrawImage(Image image, Rectangle rect)
Parameters
Type |
Name |
Description |
Image |
image |
|
System.Drawing.Rectangle |
rect |
|
DrawImage(Image, Rectangle, Rectangle)
Declaration
public void DrawImage(Image image, Rectangle src, Rectangle dest)
Parameters
Type |
Name |
Description |
Image |
image |
|
System.Drawing.Rectangle |
src |
|
System.Drawing.Rectangle |
dest |
|
DrawImage(Image, RectangleF)
Declaration
public void DrawImage(Image image, RectangleF rect)
Parameters
Type |
Name |
Description |
Image |
image |
|
System.Drawing.RectangleF |
rect |
|
DrawImage(Image, RectangleF, RectangleF)
Declaration
public void DrawImage(Image image, RectangleF src, RectangleF dest)
Parameters
Type |
Name |
Description |
Image |
image |
|
System.Drawing.RectangleF |
src |
|
System.Drawing.RectangleF |
dest |
|
DrawImage(Image, Int32, Int32, Int32, Int32)
Declaration
public void DrawImage(Image image, int x, int y, int w, int h)
Parameters
Type |
Name |
Description |
Image |
image |
|
System.Int32 |
x |
|
System.Int32 |
y |
|
System.Int32 |
w |
|
System.Int32 |
h |
|
DrawImage(Image, Single, Single, Single, Single)
Declaration
public void DrawImage(Image image, float x, float y, float w, float h)
Parameters
Type |
Name |
Description |
Image |
image |
|
System.Single |
x |
|
System.Single |
y |
|
System.Single |
w |
|
System.Single |
h |
|
DrawImageUnscaled(Image, Point)
Draws image of the original size at the specified location
Declaration
public void DrawImageUnscaled(Image image, Point p)
Parameters
Type |
Name |
Description |
Image |
image |
|
System.Drawing.Point |
p |
|
DrawImageUnscaled(Image, PointF)
Draws image of the original size at the specified location
Declaration
public void DrawImageUnscaled(Image image, PointF p)
Parameters
Type |
Name |
Description |
Image |
image |
|
System.Drawing.PointF |
p |
|
DrawImageUnscaled(Image, Int32, Int32)
Draws image of the original size at the specified location
Declaration
public void DrawImageUnscaled(Image image, int x, int y)
Parameters
Type |
Name |
Description |
Image |
image |
|
System.Int32 |
x |
|
System.Int32 |
y |
|
DrawImageUnscaled(Image, Single, Single)
Draws image of the original size at the specified location
Declaration
public void DrawImageUnscaled(Image image, float x, float y)
Parameters
Type |
Name |
Description |
Image |
image |
|
System.Single |
x |
|
System.Single |
y |
|
DrawLine(Canvas.Pen, Point, Point)
Declaration
public void DrawLine(Canvas.Pen pen, Point p1, Point p2)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Drawing.Point |
p1 |
|
System.Drawing.Point |
p2 |
|
DrawLine(Canvas.Pen, PointF, PointF)
Declaration
public void DrawLine(Canvas.Pen pen, PointF p1, PointF p2)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Drawing.PointF |
p1 |
|
System.Drawing.PointF |
p2 |
|
DrawLine(Canvas.Pen, Int32, Int32, Int32, Int32)
Declaration
public void DrawLine(Canvas.Pen pen, int x1, int y1, int x2, int y2)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Int32 |
x1 |
|
System.Int32 |
y1 |
|
System.Int32 |
x2 |
|
System.Int32 |
y2 |
|
DrawLine(Canvas.Pen, Single, Single, Single, Single)
Declaration
public void DrawLine(Canvas.Pen pen, float x1, float y1, float x2, float y2)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Single |
x1 |
|
System.Single |
y1 |
|
System.Single |
x2 |
|
System.Single |
y2 |
|
DrawRectangle(Canvas.Pen, Rectangle)
Declaration
public void DrawRectangle(Canvas.Pen pen, Rectangle rect)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Drawing.Rectangle |
rect |
|
DrawRectangle(Canvas.Pen, RectangleF)
Declaration
public void DrawRectangle(Canvas.Pen pen, RectangleF rect)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Drawing.RectangleF |
rect |
|
DrawRectangle(Canvas.Pen, Int32, Int32, Int32, Int32)
Declaration
public void DrawRectangle(Canvas.Pen pen, int x, int y, int w, int h)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Int32 |
x |
|
System.Int32 |
y |
|
System.Int32 |
w |
|
System.Int32 |
h |
|
DrawRectangle(Canvas.Pen, Single, Single, Single, Single)
Declaration
public void DrawRectangle(Canvas.Pen pen, float x, float y, float w, float h)
Parameters
Type |
Name |
Description |
Canvas.Pen |
pen |
|
System.Single |
x |
|
System.Single |
y |
|
System.Single |
w |
|
System.Single |
h |
|
DrawString(Canvas.Font, Canvas.Brush, String, PointF)
Declaration
public void DrawString(Canvas.Font font, Canvas.Brush brush, string text, PointF p)
Parameters
DrawString(Canvas.Font, Canvas.Brush, String, Single, Single)
Declaration
public void DrawString(Canvas.Font font, Canvas.Brush brush, string text, float x, float y)
Parameters
FillRectangle(Canvas.Brush, Point, Size)
Declaration
public void FillRectangle(Canvas.Brush brush, Point p, Size s)
Parameters
Type |
Name |
Description |
Canvas.Brush |
brush |
|
System.Drawing.Point |
p |
|
System.Drawing.Size |
s |
|
FillRectangle(Canvas.Brush, PointF, SizeF)
Declaration
public void FillRectangle(Canvas.Brush brush, PointF p, SizeF s)
Parameters
Type |
Name |
Description |
Canvas.Brush |
brush |
|
System.Drawing.PointF |
p |
|
System.Drawing.SizeF |
s |
|
FillRectangle(Canvas.Brush, Rectangle)
Declaration
public void FillRectangle(Canvas.Brush brush, Rectangle rect)
Parameters
Type |
Name |
Description |
Canvas.Brush |
brush |
|
System.Drawing.Rectangle |
rect |
|
FillRectangle(Canvas.Brush, RectangleF)
Declaration
public void FillRectangle(Canvas.Brush brush, RectangleF rect)
Parameters
Type |
Name |
Description |
Canvas.Brush |
brush |
|
System.Drawing.RectangleF |
rect |
|
FillRectangle(Canvas.Brush, Int32, Int32, Int32, Int32)
Declaration
public void FillRectangle(Canvas.Brush brush, int x, int y, int w, int h)
Parameters
Type |
Name |
Description |
Canvas.Brush |
brush |
|
System.Int32 |
x |
|
System.Int32 |
y |
|
System.Int32 |
w |
|
System.Int32 |
h |
|
FillRectangle(Canvas.Brush, Single, Single, Single, Single)
Declaration
public void FillRectangle(Canvas.Brush brush, float x, float y, float w, float h)
Parameters
Type |
Name |
Description |
Canvas.Brush |
brush |
|
System.Single |
x |
|
System.Single |
y |
|
System.Single |
w |
|
System.Single |
h |
|
MeasureString(Canvas.Font, String, Nullable<SizeF>)
Measures the size of text rendered in the font within the optional bounds
Declaration
public SizeF MeasureString(Canvas.Font font, string text, SizeF? bounds)
Parameters
Type |
Name |
Description |
Canvas.Font |
font |
|
System.String |
text |
|
System.Nullable<System.Drawing.SizeF> |
bounds |
|
Returns
Type |
Description |
System.Drawing.SizeF |
|
Implements
System.IDisposable
Extension Methods