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: RSGraphics
Delphi
|
type
TCanvasColor = TColor;
|
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
•RSGraphics.DrawShape(TCanvas,TCanvasRect,TBitmap,TRSShapeStyle,Boolean,TCanvasColor,TCanvasColor,TCanvasPixel,Single) •RSGraphics.DrawArrow(TCanvas,TRSPoints,TCanvasPixel,String,TArrowOptions,TCanvasPixel,TCanvasPixel,Single) •RSGraphics.CanvasColorToString(TCanvasColor) •RSGraphics.StringToCanvasColor(String) •RSGraphics.clxBlack •RSGraphics.clxWhite •RSGraphics |