Table of Contents

Class AndroidDrawingContext

Namespace
Xui.Runtime.Android.Actual
Assembly
Xui.Runtime.Android.dll
public class AndroidDrawingContext : IContext, IMeasureContext, IStateContext, IPenContext, IPathDrawingContext, IPathBuilder, IGlyphPathBuilder, IPathDrawing, IPathClipping, IRectDrawingContext, ITextDrawingContext, ITextMeasureContext, IImageDrawingContext, ITransformContext, IDisposable
Inheritance
AndroidDrawingContext
Implements
Inherited Members

Constructors

AndroidDrawingContext()

public AndroidDrawingContext()

Properties

Canvas

public Canvas? Canvas { get; set; }

Property Value

Canvas?

GlobalAlpha

Sets the global alpha value for all drawing operations. Range: 0.0 (fully transparent) to 1.0 (fully opaque).

public NFloat GlobalAlpha { set; }

Property Value

NFloat

LineCap

Sets the style of line caps used for strokes.

public LineCap LineCap { set; }

Property Value

LineCap

LineDashOffset

Sets the phase offset for the start of the dash pattern.

public NFloat LineDashOffset { get; set; }

Property Value

NFloat

LineJoin

Sets the style of line joins between segments.

public LineJoin LineJoin { set; }

Property Value

LineJoin

LineWidth

Sets the width of stroked lines, in user space units.

public NFloat LineWidth { set; }

Property Value

NFloat

MiterLimit

Sets the miter limit ratio for miter joins. If the ratio of miter length to line width exceeds this value, a bevel join is used instead.

public NFloat MiterLimit { set; }

Property Value

NFloat

TextAlign

Sets the horizontal alignment of the text relative to the given position.

public TextAlign TextAlign { set; }

Property Value

TextAlign

TextBaseline

Sets the vertical alignment of the text relative to the given baseline.

public TextBaseline TextBaseline { set; }

Property Value

TextBaseline

Methods

Arc(Point, NFloat, NFloat, NFloat, Winding)

Adds an arc to the path centered at the specified point.

public void Arc(Point center, NFloat radius, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise)

Parameters

center Point

Center of the arc.

radius NFloat

Radius of the arc.

startAngle NFloat

Start angle in radians.

endAngle NFloat

End angle in radians.

winding Winding

Direction in which the arc is drawn.

ArcTo(Point, Point, NFloat)

Adds an arc to the path, connecting two tangents defined by control points.

public void ArcTo(Point cp1, Point cp2, NFloat radius)

Parameters

cp1 Point

First control point.

cp2 Point

Second control point.

radius NFloat

Arc radius.

BeginPath()

Begins a new path by resetting the current path list.

public void BeginPath()

Clip()

Sets the current clipping region to the current path. Subsequent drawing operations are clipped to this region.

public void Clip()

ClosePath()

Closes the current path contour.

public void ClosePath()

CurveTo(Point, Point)

Draws a quadratic Bézier curve using a control point and end point.

public void CurveTo(Point cp1, Point to)

Parameters

cp1 Point
to Point

CurveTo(Point, Point, Point)

Draws a cubic Bézier curve from the current point to the specified point, using two control points.

public void CurveTo(Point cp1, Point cp2, Point to)

Parameters

cp1 Point

First control point.

cp2 Point

Second control point.

to Point

End point.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Ellipse(Point, NFloat, NFloat, NFloat, NFloat, NFloat, Winding)

Adds an elliptical arc to the path.

public void Ellipse(Point center, NFloat radiusX, NFloat radiusY, NFloat rotation, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise)

Parameters

center Point

Center of the ellipse.

radiusX NFloat

Horizontal radius.

radiusY NFloat

Vertical radius.

rotation NFloat

Rotation of the ellipse, in radians.

startAngle NFloat

Start angle in radians.

endAngle NFloat

End angle in radians.

winding Winding

Direction in which the arc is drawn.

Fill(FillRule)

Fills the current path using the specified fill rule.

public void Fill(FillRule rule = FillRule.NonZero)

Parameters

rule FillRule

The fill rule to use (NonZero or EvenOdd).

FillRect(Rect)

Fills the specified rectangle using the current fill style.

public void FillRect(Rect rect)

Parameters

rect Rect

The rectangle to fill.

FillText(string, Point)

Draws filled text at the specified position using the current fill style and font settings.

public void FillText(string text, Point pos)

Parameters

text string

The text string to render.

pos Point

The position at which to start rendering the text.

LineTo(Point)

Draws a straight line to the specified point.

public void LineTo(Point to)

Parameters

to Point

MeasureText(string)

public Vector MeasureText(string text)

Parameters

text string

Returns

Vector

MoveTo(Point)

Begins a new sub-path at the specified point.

public void MoveTo(Point to)

Parameters

to Point

Rect(Rect)

Adds a rectangle path to the current path.

public void Rect(Rect rect)

Parameters

rect Rect

The rectangle to add.

Restore()

Pops the top state off the state stack and restores it. Any modifications made since the last Save() are discarded.

public void Restore()

Rotate(NFloat)

Applies a clockwise rotation to the current transform.

public void Rotate(NFloat angle)

Parameters

angle NFloat

The rotation angle in radians.

RoundRect(Rect, NFloat)

Adds a rounded rectangle path with a uniform radius.

public void RoundRect(Rect rect, NFloat radius)

Parameters

rect Rect

The rectangle to round.

radius NFloat

Corner radius.

RoundRect(Rect, CornerRadius)

Adds a rounded rectangle path with per-corner radii.

public void RoundRect(Rect rect, CornerRadius radius)

Parameters

rect Rect

The rectangle to round.

radius CornerRadius

Corner radius object defining each corner.

Save()

Pushes the current drawing state onto the state stack. This includes styles, transformations, clipping paths, etc.

public void Save()

Scale(Vector)

Applies a scaling transformation using the specified scaling factors.

public void Scale(Vector vector)

Parameters

vector Vector

The scaling vector (sx, sy).

SetFill(Color)

Sets the fill style to a solid color.

public void SetFill(Color color)

Parameters

color Color

The fill color.

SetFill(LinearGradient)

Sets the fill style to a linear gradient.

public void SetFill(LinearGradient linearGradient)

Parameters

linearGradient LinearGradient

The gradient to use for filling shapes.

SetFill(RadialGradient)

Sets the fill style to a radial gradient.

public void SetFill(RadialGradient radialGradient)

Parameters

radialGradient RadialGradient

The gradient to use for filling shapes.

SetFont(Font)

Sets the font used for all subsequent text drawing and measurement operations.

public void SetFont(Font font)

Parameters

font Font

The font definition to apply.

SetLineDash(ReadOnlySpan<NFloat>)

Sets the dash pattern used for stroking lines. Each element in the span represents a dash or gap length, alternating.

public void SetLineDash(ReadOnlySpan<NFloat> segments)

Parameters

segments ReadOnlySpan<NFloat>

A sequence of dash and gap lengths.

SetStroke(Color)

Sets the stroke style to a solid color.

public void SetStroke(Color color)

Parameters

color Color

The stroke color.

SetStroke(LinearGradient)

Sets the stroke style to a linear gradient.

public void SetStroke(LinearGradient linearGradient)

Parameters

linearGradient LinearGradient

The gradient to use for stroking paths.

SetStroke(RadialGradient)

Sets the stroke style to a radial gradient.

public void SetStroke(RadialGradient radialGradient)

Parameters

radialGradient RadialGradient

The gradient to use for stroking paths.

SetTransform(AffineTransform)

Resets the current transformation matrix to the identity matrix, then replaces it with the specified transform. Equivalent to ctx.setTransform(...) in HTML5 Canvas.

public void SetTransform(AffineTransform transform)

Parameters

transform AffineTransform

The new transformation matrix to apply.

Stroke()

Strokes the current path using the current stroke style.

public void Stroke()

StrokeRect(Rect)

Draws the outline of the specified rectangle using the current stroke style.

public void StrokeRect(Rect rect)

Parameters

rect Rect

The rectangle to stroke.

Transform(AffineTransform)

Multiplies the current transformation matrix by the specified matrix. This is equivalent to applying an additional transformation on top of the existing one.

public void Transform(AffineTransform matrix)

Parameters

matrix AffineTransform

The matrix to multiply with the current transform.

Translate(Vector)

Applies a translation by the specified vector. This offsets all subsequent drawing operations by the given amount.

public void Translate(Vector vector)

Parameters

vector Vector

The translation vector (dx, dy).