Defines a cross-library (VCL or FMX) color type. In VCL, the color type is TColor and in FMX the color type is TAlphaColor.
Use the TCanvasColor type to write cross-library code. The clxCOLOR constants define cross-library constants for setting colors.
Namespace: FMX.RS.Graphics
Delphi
|
type
TCanvasColor = TAlphaColor;
|
The following is a example of using the CanvasXXX types, constants, and functions to write cross-library graphics code:
Delphi
|
{$DEFINE FMX} // should only define in FMX applications only
var
CenterPt: TCanvasPoint;
LowerRightQuadrant: TCanvasRect;
begin
// get center point using cross-library CenterPoint
CenterPt := CanvasCenterPoint(ARect);
// create a rectangle using cross-library Rect
LowerRightQuadrant := CanvasRect(CenterPt.X, CenterPt.Y, ARect.Right, ARect.Bottom);
// FMX does not have Canvas.Pen property, it is exposed by FMX.RS.CanvasHelper
// as equivalent to Canvas.Stroke
// clxCOLORS are from RSGraphics
Canvas.Pen.Color := clxBlue;
// FMX does not have Canvas.Brush property, it is exposed in FMX.RS.CanvasHelper
// as equivalent to Canvas.Fill
Canvas.Brush.Color := clxRed;
{$IFDEF FMX}
Canvas.StrokeDash := TStrokeDash.sdDash; // <--- not cross-library compatible
{$ELSE}
Canvas.Pen.Style := psDash; // <--- not cross-library compatible
{$ENDIF}
// FMX does not have Canvas.Rectangle method, added in FMX.RS.CanvasHelper
Canvas.Rectangle(LowerRightQuadrant);
// Move text down by around a third of width/height of LowerRightQuadrant, use
// CanvasDiv function from RSGraphics to make the code cross-library
Canvas.TextOut( CenterPt.X + CanvasDiv(LowerRightQuadrant.Width,3.3),
CenterPt.Y + CanvasDiv(LowerRightQuadrant.Height,3.3),
'Hello World' );
end;
|
|
Reference
•FMX.RS.Graphics.DrawShape(TCanvas,TCanvasRect,TBitmap,TRSShapeStyle,Boolean,TCanvasColor,TCanvasColor,TCanvasPixel,Single) •FMX.RS.Graphics.DrawArrow(TCanvas,TRSPoints,TCanvasPixel,String,TArrowOptions,TCanvasPixel,TCanvasPixel,Single,TCanvasColor) •FMX.RS.Graphics.CanvasColorToString(TCanvasColor) •FMX.RS.Graphics.StringToCanvasColor(String) •FMX.RS.Graphics.clxBlack •FMX.RS.Graphics.clxWhite •FMX.RS.Graphics |