Creates a TCanvasRect from the input coordinates.
Note
|
This function eases cross-library graphics code by using TCanvasXXX types and CanvasXXX functions. With these functions, types, and constants, you can write code that can be used in either a VCL or FMX application. It is recommended that you write the VCL code first as it is more limited that the FMX library.
|
Namespace: FMX.RS.Graphics
Delphi
|
function CanvasRect( Left, Top, Right, Bottom: Single ): TCanvasRect; inline; overload;
|
Parameters
Left
Type: Single
Top
Type: Single
Right
Type: Single
Bottom
Type: Single
Return Value
Type: TCanvasRect
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.TCanvasRect •FMX.RS.Graphics.CanvasRect(Integer,Integer,Integer,Integer) •FMX.RS.Graphics.CanvasRect(Single,Single,Single,Single) •FMX.RS.Graphics.CanvasRect(TRect) •FMX.RS.Graphics.CanvasRect(TRSRect) •FMX.RS.Graphics.CanvasPoint(Integer,Integer) •FMX.RS.Graphics.CanvasPoint(Single,Single) •FMX.RS.Graphics.CanvasRound(Double) •FMX.RS.Graphics.CanvasTrunc(Double) •FMX.RS.Graphics.CanvasDiv(Double,Double) •FMX.RS.Graphics.CanvasDiv(Int64,Int64) •FMX.RS.Graphics.CanvasMax(TCanvasPixel[]) •FMX.RS.Graphics.CanvasMin(TCanvasPixel[]) •FMX.RS.Graphics.CanvasCenterPoint(TCanvasRect) •FMX.RS.Graphics |