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

DefaultVertTextDirection

Specifies the default vertical text direction used when no direction is provided.

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.

Canvas

Gets the SkiaSharp canvas associated with this Graphics object. Use SkiaEnabled to check if this property is supported before accessing it.

ClipBounds

Gets the bounds of the current clipping region of this Graphics object.

ConfigIdentity

Gets the graphics configuration identity for this Graphics instance.

DrawImagePaintSettings

Gets the SKPaint used for drawing images, based on the current InterpolationMode and other settings.

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.

SamplingOptions

Gets or sets the sampling options used for drawing images. If not specified, the default sampling options Default will be used.

ScaleFactor

Gets used scale factor.

SkiaEnabled

Gets a value indicating whether the SkiaSharp canvas is supported via Canvas property. If false, the Canvas property will throw an exception if accessed.

SmoothingMode

Gets or sets the current smoothing mode for this Graphics instance.

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.

DrawArc(Pen, RectD, float, float)

Draws an arc representing a portion of an ellipse specified by a bounding rectangle.

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

Draws an arc representing a portion of an ellipse specified by a bounding rectangle.

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.

DrawBitmap(SKBitmap, PointD)

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

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.

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

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

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

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

DrawString(ReadOnlySpan<char>, Font, Brush, float, float)

Draws the text string at the specified location using the specified font and brush.

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>, Font, Brush?, RectD, in Record)

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.

DrawTextLinesWithFontStyle(TextAndFontStyle[][], float, PointD, Font, Color, Color?)

Draws multiple lines of text, each with individual font style segments, at the specified location and returns the size of each rendered line.

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 custom font styles and colors.

DrawVertText(ReadOnlySpan<char>, Font, Color, RectD, VerticalTextDirection?)

Draws text vertically in the specified rectangle using the given font and colors, based on the specified vertical text direction.

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

Draws text vertically starting from the bottom of the specified rectangle using the given font and colors. Text is centered within the rectangle, and the method handles rotation and translation to achieve the desired orientation.

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

Draws text vertically starting from the top of the specified rectangle using the given font and colors. Text is centered within the rectangle, and the method handles rotation and translation to achieve the desired orientation.

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.

FillOrDrawCircle(Pen?, Brush?, PointD, float)

Fills and/or draws the border of the specified circle.

FillOrDrawEllipse(Pen?, Brush?, RectD)

Fills and/or draws the border of the specified ellipse.

FillOrDrawPie(Pen?, Brush?, PointD, float, float, float)

Fills and/or draws the border of the specified pie.

FillOrDrawRectangle(Pen?, Brush?, RectD)

Fills and/or draws the border of the specified rectangle.

FillOrDrawRoundedRectangle(Pen?, Brush?, RectD, float)

Fills and/or draws the border of the specified rounded rectangle.

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.

GetDPI()

Returns the DPI of the display used by this object.

GetEffectiveSamplingOptions()

Gets the effective sampling options used for drawing images, taking into account the SamplingOptions property.

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.

Restore(GraphicsState)

Restores the canvas to the specified state.

RotateTransform(float)

Applies the specified rotation to the transformation matrix of this graphics in the prepend order.

RotateTransform(float, MatrixOrder)

Applies the specified rotation to the transformation matrix of this graphics in the specified order.

RoundedRectangle(Pen, Brush, RectD, float)

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

Save()

Saves the current state of the canvas.

ScaleTransform(float, float)

Changes the scale of the coordinate system by applying the specified scale factors to the transformation matrix of this graphics in the prepend order.

ScaleTransform(float, float, MatrixOrder)

Changes the scale of the coordinate system by applying the specified scale factors to the transformation matrix of this graphics in the specified order.

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.

TranslateTransform(float, float)

Changes the origin of the coordinate system by prepending the specified translation to the transformation matrix of this graphics.

TranslateTransform(float, float, MatrixOrder)

Changes the origin of the coordinate system by applying the specified translation to the transformation matrix of this graphics in the specified order.