Table of Contents

Class Graphics

Namespace
Alternet.Drawing
Assembly
Alternet.UI.Common.dll

Defines a custom drawing surface.

public abstract class Graphics : DisposableObject, IBaseObjectWithAttr, IBaseObjectWithId, INotifyPropertyChanged, IDisposableObject, IBaseObject, IGraphics, IDisposable
Inheritance
Graphics
Implements
Derived
Extension Methods

Fields

DrawDebugCorners

Gets or sets whether debug corners are painted in some of the graphics methods.

MaxCoord

This is max coordinate value used for the layout purposes.

Properties

BackendType

Gets the type of graphics backend used by the implementation.

ConfigIdentity

Gets the graphics configuration identity for this Graphics instance.

HasTransform

Gets whether Transform is assigned with transform matrix which is not the identity matrix.

HorizontalScaleFactor

Gets horizontal scale factor.

InterpolationMode

Gets or sets the interpolation mode associated with this Graphics.

IsOk

Returns true if the object is ok to use.

Name

Gets or sets name of the Graphics for the debug purposes.

NativeObject

Gets native drawing context.

ScaleFactor

Gets used scale factor.

Transform

Gets or sets a copy of the geometric world transformation for this Graphics.

TransformDXDY

Gets the displacement values (DX and DY) from the current transformation. Returns an empty point if no transformation is applied.

TransformStackDepth

Gets the current depth of the transform stack.

VerticalScaleFactor

Gets vertical scale factor.

Methods

CharPairSize(char, Font)

Returns the size of a pair of identical characters when drawn with the specified font.

CharSize(char, Font)

Returns the size of a single character when drawn with the specified font.

CharSize(char, int, Font)

Returns the size of a sequence of identical characters when drawn with the specified font.

CheckTransformStackDepth(Action)

Ensures that the transform stack depth remains balanced before and after the specified action is executed.

Circle(Pen, Brush, PointD, float)

Calls FillCircle(Brush, PointD, float) and than DrawCircle(Pen, PointD, float).

ClipRect(RectD, bool)

Clips the canvas to the specified rectangle.

ClipRegion(Region)

Modify the current clip with the specified region.

DebugAssert(Pen, Brush)

Checks whether Pen and Brush parameters are ok.

DebugBezierPointsAssert(ReadOnlySpan<PointD>)

Checks whether array of PointD parameter is ok.

DebugBrushAssert(Brush)

Checks whether Brush parameter is ok.

DebugColorAssert(Color, string?)

Checks whether Color parameter is ok.

DebugFontAssert(Font)

Checks whether Font parameter is ok.

DebugFormatAssert(TextFormat)

Checks whether TextFormat parameter is ok.

DebugImageAssert(Image)

Checks whether Image parameter is ok.

DebugPenAssert(Pen)

Checks whether Pen parameter is ok.

DebugSolidBrushAssert(Brush)

Checks whether SolidBrush parameter is ok.

DebugTextAssert(ReadOnlySpan<char>)

Checks whether string parameter is ok.

DoInsideClipped(RectD, Action, bool)

Calls the specified action inside temporary clipped rectangle, so painting outside this rectangle is ignored.

DoInsideClipped(Region, Action, bool)

Calls the specified action inside temporary clipped region, so painting outside this region is ignored.

DrawArc(Pen, PointD, float, float, float)

Draws an arc representing a portion of a circle specified by a center PointD and a radius.

DrawBezier(Pen, PointD, PointD, PointD, PointD)

Draws a Bezier spline defined by four PointD structures.

DrawBeziers(Pen, ReadOnlySpan<PointD>)

Draws a series of Bezier splines from an array of PointD structures.

DrawCircle(Pen, PointD, float)

Draws an circle specified by a center PointD and a radius.

DrawDebugPoints(RectD, Pen?)

Draws debug points on the corners of the specified rectangle.

DrawElements(ref DrawElementsParams)

Draws array of elements specified with Graphics.DrawElementsParams.

DrawEllipse(Pen, RectD)

Draws an ellipse defined by a bounding RectD.

DrawImage(Image, PointD)

Draws the specified Image, using its original size, at the specified location.

DrawImage(Image, RectD)

Draws an image into the region defined by the specified RectD.

DrawImage(Image, float, float)

Draws the specified Image, using its original size, at the specified location.

DrawImageUnscaled(Image, PointD)

Draws the specified Image, using its original size, at the specified location.

DrawLabel(ref DrawLabelParams)

Draws text with the specified font, background and foreground colors, optional image, alignment and underlined mnemonic character.

DrawLabel(ReadOnlySpan<char>, Font, Color, Color, Image?, RectD, HVAlignment?, int)

Draws text with the specified font, background and foreground colors, optional image, alignment and underlined mnemonic character.

DrawLabelUnclipped(ref DrawLabelParams)

Draws text with the specified font, background and foreground colors, optional image, alignment and underlined mnemonic character. This is unclipped version of DrawLabel(ref DrawLabelParams).

DrawLine(Pen, PointD, PointD)

Draws a line connecting two points.

DrawLine(Pen, float, float, float, float)

Draws a line connecting two points.

DrawLines(Pen, ReadOnlySpan<PointD>)

Draws a series of line segments that connect an array of PointD structures.

DrawPath(Pen, GraphicsPath)

Draws a GraphicsPath.

DrawPie(Pen, PointD, float, float, float)

Draws an outline of a pie section defined by a circle specified by a center PointD and a radius.

DrawPointAtCenter(Color, RectD)

Draws point at the center of the specified rectangle.

DrawPolygon(Pen, ReadOnlySpan<PointD>)

Draws a polygon defined by an array of PointD structures.

DrawRectangle(Pen, RectD)

Draws a rectangle specified by a RectD structure.

DrawRectangles(Pen, ReadOnlySpan<RectD>)

Draws a series of rectangles specified by RectD structures.

DrawRoundedRectangle(Pen, RectD, float)

Draws a rounded rectangle specified by a RectD and a corner radius.

DrawStrings(RectD, Font, IEnumerable<string>?, TextHorizontalAlignment, float, Color?, Color?)

Draws range of strings.

DrawText(ReadOnlySpan<char>, Font, Brush, PointD)

Draws text string with the specified location, Brush and Font objects.

DrawText(ReadOnlySpan<char>, Font, Brush, RectD)

Draws text string with the specified bounds, Brush and Font objects.

DrawText(ReadOnlySpan<char>, Font, Brush, RectD, TextFormat)

Draws the text string at the specified location with Brush and Font objects.

DrawText(ReadOnlySpan<char>, PointD)

Draws text with DefaultFont and Default.

DrawText(ReadOnlySpan<char>, PointD, Font, Color, Color)

Draws text with the specified font, background and foreground colors. This is the fastest method to draw text.

DrawText(ReadOnlySpan<char>, RectD, Font, Color, Color)

Draws text inside the bounds with the specified font, background and foreground colors.

DrawTextWithAngle(ReadOnlySpan<char>, PointD, Font, Color, Color, float)

Draws text with the specified angle, font, background and foreground colors.

DrawTextWithBoldTags(ReadOnlySpan<char>, PointD, Font, Color, Color?)

Draws text with html bold tags.

DrawTextWithFontStyle(TextAndFontStyle[], PointD, Font, Color, Color?)

Draws an array of text elements with font styles.

DrawWave(RectD, Color)

Draws waved line in the specified rectangular area.

Ellipse(Pen, Brush, RectD)

Calls FillEllipse(Brush, RectD) and than DrawEllipse(Pen, RectD).

FillCircle(Brush, PointD, float)

Fills the interior of a circle specified by a center PointD and a radius.

FillEllipse(Brush, RectD)

Fills the interior of an ellipse defined by a bounding rectangle specified by a RectD structure.

FillGradient(RectD, Color, Color, PointD, PointD)

Fills the specified rectangle with a linear gradient defined by the given colors and points.

FillPath(Brush, GraphicsPath)

Fills the interior of a GraphicsPath.

FillPie(Brush, PointD, float, float, float)

Fills the interior of a pie section defined by a circle specified by a center PointD and a radius.

FillPolygon(Brush, ReadOnlySpan<PointD>, FillMode)

Fills the interior of a polygon defined by an array of PointD structures.

FillRectangle(Brush, RectD)

Fills the interior of a rectangle specified by a RectD structure. Rectangle is specified in device-independent units.

FillRectangle(Brush, RectD, GraphicsUnit)

Fills the interior of a rectangle specified by a RectD structure. Rectangle is specified in device-independent units.

FillRectangle(Brush, float, float, float, float)

Fills the interior of a rectangle specified by a pair of coordinates, a width, and a height.

FillRectangleAtCenter(Brush, RectD, SizeD)

Draws point at the center of the specified rectangle.

FillRectangleWithColor(Color, RectD)

Fills the specified rectangle with the given color.

FillRectangles(Brush, ReadOnlySpan<RectD>)

Fills a series of rectangles specified by RectD structures.

FillRoundedRectangle(Brush, RectD, float)

Fills the interior of a rounded rectangle specified by a RectD and a corner radius.

FromImage(Image)

Creates a new Graphics from the specified Image.

FromScreen()

Creates Graphics that can be used to paint on the screen.

GetDPI()

Returns the DPI of the display used by this object.

GetHdc()

Gets the handle to the device context associated with this Graphics. The following values are returned by wxWidgets backend: on Windows the return value is an HDC, on macOS it is a CGContextRef and on wxGTK it will be a GdkDrawable.

GetTextExtent(ReadOnlySpan<char>, Font)

Gets the dimensions of the string using the specified font.

InterCharSpacing(char, Font, out SizeD, out float)

Calculates the size of a single character and the spacing between two consecutive characters.

MeasureText(ReadOnlySpan<char>, Font)

Measures the specified string when drawn with the specified Font. Calls internally GetTextExtent(ReadOnlySpan<char>, Font).

Path(Pen, Brush, GraphicsPath)

Calls FillPath(Brush, GraphicsPath) and than DrawPath(Pen, GraphicsPath).

Pie(Pen, Brush, PointD, float, float, float)

Calls FillPie(Brush, PointD, float, float, float) and than DrawPie(Pen, PointD, float, float, float).

Polygon(Pen, Brush, ReadOnlySpan<PointD>, FillMode)

Calls FillPolygon(Brush, ReadOnlySpan<PointD>, FillMode) and than DrawPolygon(Pen, ReadOnlySpan<PointD>).

PopTransform()

Pops a stored transformation matrix from the stack and sets it to the Transform property.

PushAndTranslate(float, float)

Creates translation matrix and calls PushTransform(TransformMatrix) with it.

PushTransform()

Pushes the current state of the transformation matrix on a stack.

PushTransform(TransformMatrix)

Pushes the current state of the Graphics transformation matrix on a stack and concatenates the current transform with a new transform.

Rectangle(Pen, Brush, RectD)

Calls FillRectangle(Brush, RectD) and than DrawRectangle(Pen, RectD).

ReleaseHdc(nint)

Releases a device context handle obtained by a previous call to the GetHdc() method of this Graphics.

RequireMeasure(ref Graphics?, CanvasCreateParams)

Updates storage with measurement canvas which can be used in order to measure text sizes.

ResetTransform()

Resets transformation matrix in the Transform property.

Restore()

Restore the saved canvas state.

RoundedRectangle(Pen, Brush, RectD, float)

Calls FillRoundedRectangle(Brush, RectD, float) and than DrawRoundedRectangle(Pen, RectD, float).

Save()

Saves the current state of the canvas.

SetHandlerTransform(TransformMatrix)

Sets transform matrix of the handler.

ToDip(ref PointD, GraphicsUnit)

Converts point to device-independent units.

ToDip(ref RectD, GraphicsUnit)

Converts rectangle to device-independent units.

ToDip(ref SizeD, GraphicsUnit)

Converts SizeD to device-independent units.

ToPixels(ref PointD, GraphicsUnit)

Converts point to pixels.