콘텐츠로 이동

IGraphicsContext interface

이 콘텐츠는 아직 번역되지 않았습니다.

Abstract interface for graphics rendering operations. Allows swapping the underlying graphics library via pluggable backends.

public interface IGraphicsContext : IDisposable
name description
DpiScale { get; } Gets the DPI scale factor of the current render target (1.0 at 96 DPI).
EnableAlphaTextHint { get; set; } Gets or sets whether text rendering must produce correct alpha channel values; backends that always do may ignore the hint.
GlobalAlpha { get; set; } Gets or sets the opacity multiplier applied to the drawing calls that follow, in the range [0, 1]. It multiplies onto the opacity the caller is drawn under, such as an ancestor’s fade or an open BeginOpacity scope, which it cannot replace. It starts at 1f and is saved and restored by Save / Restore.
ImageScaleQuality { get; set; } Gets or sets the image interpolation mode used when drawing images. Backends may treat Default as an alias for their default mode.
Text { get; } Gets the frame-bound text drawing surface.
TextPixelSnap { get; set; } Gets or sets whether text rendering snaps glyph positions to device pixels. When true (default), text is pixel-snapped for sharpness. Set to false during animations/transitions to avoid visible jumping. The value is saved and restored by Save / Restore.
BeginFrame(…) Starts a new frame for the given render target. Must be called before any drawing operations.
BeginOpacity(…) Fades everything drawn up to the matching EndOpacity as one group, so drawing that overlaps itself inside the scope fades once instead of darkening where it overlaps.
BeginOpaqueBackdrop() Declares that the drawing up to the matching EndOpaqueBackdrop starts by filling its box with an opaque colour, so text in it may use subpixel antialiasing.
Clear(…) Clears the drawing surface with the specified color.
DrawBoxShadow(…) Draws a box shadow around the specified bounds.
DrawEllipse(…) Draws an ellipse outline. (3 methods)
DrawImage(…) Draws an image at the specified location. (3 methods)
DrawLine(…) Draws a line between two points. (3 methods)
DrawPath(…) Draws a path outline. (2 methods)
DrawRectangle(…) Draws a rectangle outline. (3 methods)
DrawRoundedRectangle(…) Draws a rounded rectangle outline. (3 methods)
EndFrame() Ends the current frame. Flushes pending drawing operations. The context can be reused by calling BeginFrame again.
EndOpacity() Ends the innermost BeginOpacity scope.
EndOpaqueBackdrop() Ends the innermost BeginOpaqueBackdrop scope.
FillEllipse(…) Fills an ellipse with a solid color. (2 methods)
FillPath(…) Fills a path with a solid color. (4 methods)
FillRectangle(…) Fills a rectangle with a solid color. (2 methods)
FillRoundedRectangle(…) Fills a rounded rectangle with a solid color. (2 methods)
GetClipBoundsLocal() Returns the axis-aligned bounding box of the current clip in local (pre-transform) coordinates, or null when no clip is active.
GetTransform() Returns the current 2-D affine transform matrix.
IntersectClip(…) Intersects the current clip region with rect. Equivalent to SetClip when no clip has been set.
ResetClip() Removes all clipping regions set since the last Save.
ResetTransform() Resets the transform to the identity matrix.
Restore() Restores the state saved by the matching Save.
Rotate(…) Rotates the coordinate system by angleRadians around the current origin. Positive angles rotate clockwise (screen-space convention).
Save() Saves the current graphics state (transform, clip, GlobalAlpha, TextPixelSnap).
Scale(…) Scales the coordinate system by the given factors.
SetClip(…) Sets the clipping region.
SetClipPath(…) Intersects the current clip with the interior of path. Inside/outside is determined by FillRule.
SetClipRoundedRect(…) Sets a rounded-rectangle clipping region. Backends may fall back to a rectangular clip if rounded clips are not supported. (2 methods)
SetTransform(…) Replaces the current transform with the specified 2-D affine matrix.
Translate(…) Translates the origin of the coordinate system.

Coordinates, sizes and thicknesses are in DIPs under the current transform. The calls are immediate-mode, but a window records each element’s calls and replays the recording until the element is invalidated, so a context handed to OnRender is not re-entered every frame.