Table of Contents

TTMSFNCGraphics Class

Platform-independent 2D drawing engine that wraps FMX, VCL, WEB, and other framework canvases. Use an instance to draw shapes, text, bitmaps, and native UI elements in any Draw or paint override.

API unit family: TMSFNCGraphics

Syntax

TTMSFNCGraphics = class

Properties

Name Description
Bitmap The bitmap that backs this graphics instance when created with CreateBitmapCanvas or CreateNativeBitmapCanvas.
BitmapContainer Bitmap container used to resolve image names referenced in HTML text or by the DrawBitmapWithName methods.
Canvas The underlying framework canvas wrapped by this graphics instance.
Context The platform-specific rendering context that performs the actual drawing operations.
Fill Fill settings applied to all filled shapes drawn by this graphics instance.
Font Font settings applied to all text drawn by this graphics instance.
HighlightColor Background color used to highlight matched text when ApplyHilight has been called. Default is gcYellow.
HighlightFontStyle Font style applied to highlighted text spans, for example [fsBold].
HighlightTextColor Foreground text color used inside highlighted spans. Default is gcBlack.
ImageList Optional image list used as a source for images referenced by index in HTML text. VCL/FMX Desktop only.
OptimizedHTMLDrawing When True, the HTML drawing engine applies rendering optimizations that reduce memory allocation. Default is True.
Stroke Stroke settings applied to all outlined shapes drawn by this graphics instance.
URLColor Color applied to hyperlink text rendered via the HTML engine. Default is gcBlue.
URLUnderline When True, hyperlink text rendered via the HTML engine is underlined. Default is True.

Methods

Name Description
ApplyHilight Wraps occurrences of AHilight inside AText with the given HTML tag to enable visual highlight rendering.
BeginPrinting Switches the graphics context to printer output mode. Call before rendering pages to a printer; end the session with EndPrinting.
BeginScene Begins a drawing scene on the underlying canvas. Match every successful call with EndScene.
CalculateText Returns the tightest bounding rectangle that encloses AText when rendered inside ARect with the current font settings.
CalculateTextHeight Returns the rendered height of AText in pixels when constrained to ARect.
CalculateTextHeightInt Returns the single-line rendered height of AText as a whole-pixel integer using the current font.
CalculateTextInt Returns the tightest bounding rectangle that encloses a single-line AText string using the current font.
CalculateTextSize Measures the bounding size of AText when rendered inside ARect with the current font settings.
CalculateTextSizeInt Returns the single-line bounding size of AText as a TSize in integer pixels using the current font.
CalculateTextWidth Returns the rendered width of AText in pixels when constrained to ARect.
CalculateTextWidthInt Returns the single-line rendered width of AText as a whole-pixel integer using the current font.
ClipRect Restricts all subsequent drawing to the floating-point rectangle ARect. Combine with ResetClip on the context to restore the full drawing area.
ColorToHTML Converts a color value to its HTML hex string representation.
DrawArc Draws an arc defined by a floating-point center point, radii, start angle, and sweep angle using the current Stroke settings.
DrawBitmap Draws ABitmap into the double-coordinate bounding box, optionally preserving aspect ratio, stretching, centering, or cropping.
DrawBitmapPart Draws a portion of ABitmap defined by double source coordinates into a double destination rectangle.
DrawBitmapWithName Looks up a bitmap by name in the assigned BitmapContainer and draws it into the double-coordinate bounding box.
DrawButton Renders a native-style push button within ARect (TRectF).
DrawCheckBox Renders a native-style check box within ARect (TRectF).
DrawCloseButton Renders a native-style close (X) button within ARect (TRectF).
DrawCompactButton Renders a native-style compact (section header) button within ARect (TRectF).
DrawDropDownButton Renders a native-style drop-down arrow button within ARect (TRectF).
DrawEllipse Draws and fills an ellipse inscribed within the double-coordinate bounding box.
DrawExpanderButton Renders a native-style expander (tree node) button within ARect (TRectF).
DrawFocusPath Draws a focus indicator along the outline of the given path in the given AColor.
DrawFocusRectangle Draws a focus indicator rectangle defined by integer coordinates in the given AColor.
DrawLine Draws a straight line between two integer coordinate points using the current Stroke settings.
DrawPath Strokes a graphics path using the current Stroke settings.
DrawPolygon Strokes a closed polygon defined by an array of floating-point points using the current Stroke settings.
DrawPolyline Strokes an open polyline defined by an array of floating-point points using the current Stroke settings.
DrawProgressBar Renders a progress bar within ARect (TRectF) filled to AValue out of AMax.
DrawRadioButton Renders a native-style radio button within ARect (TRectF).
DrawRectangle Strokes a rectangle defined by double coordinates using the current Stroke and Fill settings.
DrawRoundRectangle Draws a rounded rectangle defined by double coordinates with the given corner radius and optional corner selection.
DrawSample Draws a representative sample of the graphics appearance into ACanvas at ARect, for use in design-time preview or palettes.
DrawScaledBitmap Selects the best-resolution bitmap from ABitmaps for the given scale factor and draws it into a TRectF bounding box.
DrawText Renders AText at a single floating-point point, optionally rotated by AAngle degrees.
EndPrinting Ends a printing session started by BeginPrinting.
EndScene Ends a drawing scene started by BeginScene.
GetAspectSize Calculates the destination width and height that fit a bitmap into a new bounding box, applying aspect-ratio, stretch, and cropping rules.
GetBitmapFromBitmapContainer Retrieves a bitmap by name from a bitmap container, optionally selecting a DPI-scaled variant.
GetColorAlpha Extracts the alpha channel from a color value. FMX only.
GetColorBlue Extracts the blue channel from a color value.
GetColorGreen Extracts the green channel from a color value.
GetColorRed Extracts the red channel from a color value.
GetMatrix Returns the current transformation matrix applied to the drawing context.
GetScaledBitmap Selects the best-resolution bitmap from a scaled bitmap collection for the given DPI scale factor.
HTMLToColor Parses an HTML hex color string and returns the equivalent color value.
PointInCircle Tests whether a point lies within a circle.
PointInPath Tests whether a floating-point point lies within a graphics path.
PointInPolygon Tests whether a floating-point point lies inside a polygon.
PointInRect Tests whether a floating-point point lies within a floating-point rectangle.
RestoreState Restores a graphics state previously captured by SaveState.
SaveState Saves the current graphics state (fill, stroke, font, and transform) and returns a token that can be passed to RestoreState to revert.
SetDefaultGraphicColors Resets all class-level default graphic colors (DefaultButtonFillColor, DefaultSelectionFillColor, etc.) to their built-in values.
SetFill Applies fill settings to the drawing context, overriding the current Fill property values.
SetFillColor Changes the fill color without altering other fill settings.
SetFillKind Changes the fill kind without altering other fill settings.
SetFont Applies all settings from a font object to the drawing context, overriding the current Font property values.
SetFontColor Changes the font color without altering other font settings.
SetFontName Changes the font family name without altering other font settings.
SetFontSize Changes the font size in points without altering other font settings.
SetFontStyles Changes the font style set without altering other font settings.
SetMatrix Applies a transformation matrix to the drawing context, replacing the current transform.
SetStroke Applies stroke settings to the drawing context, overriding the current Stroke property values.
SetStrokeColor Changes the stroke color without altering other stroke settings.
SetStrokeKind Changes the stroke kind without altering other stroke settings.
SetStrokeWidth Changes the stroke width in pixels without altering other stroke settings.
StartSpecialPen Activates the special-pen drawing mode, which alters stroke rendering for certain platform-specific effects. Match every call with StopSpecialPen.
StopSpecialPen Deactivates the special-pen drawing mode started by StartSpecialPen.
TextToColor Parses a named color string and returns the equivalent color value.

Used by