適用状況:
- フォームに円を書きたい
課題:
- 描画方法の理解
- 最小限のサンプルソースの提供
方法:
3つの手法が考えられる。
- IDEのデザイン機能を利用して描画する
- Tcircleオブジェクトを使って描画する
- Canvas.DrawEllipseを使って描画する
ここでは、2の手法を用いる。
機能仕様:
| 機能 | 仕様 |
|---|---|
| 名前 | TCircle |
| 型 | class(TEllipse) |
| インクルードユニット | FMX.Objects |
| Delphiヘルプ | FMX.Objects.TCircle |
// NOTE =============================================
// Title : DrawCircle
// =================================================
// License : MIT
// Author : Penguin-Works
// Make : 2013/08/18
// Finish : 2013/08/18
// LastSave : 2013/08/18
// =================================================
// Abstruct :
// TCircleを使って、Formに円を描画する
// =================================================
unit DrawCircleObjectUnit ;
interface
uses
System.SysUtils ,
System.Types ,
System.UITypes ,
System.Rtti ,
System.Classes ,
System.Variants ,
FMX.Types ,
FMX.Controls ,
FMX.Forms ,
FMX.Layouts , // For TLayout
FMX.Objects , // For TCircle
FMX.Dialogs ;
type
TForm1 = class( TForm )
procedure FormCreate( Sender : TObject ) ;
private
public
end ;
var
Form1 : TForm1 ;
implementation
{$R *.fmx}
procedure TForm1.FormCreate( Sender : TObject ) ;
// ================================================
//
// ================================================
var
_circle : Tcircle ;
_left , _top , _right , _bottom : Single ;
begin
_left := 10 ;
_top := 10 ;
_right := 20 ;
_bottom := 20 ;
Form1.BeginUpdate ;
_circle := Tcircle.Create( nil ) ;
_circle.Parent := Form1 ;
_circle.SetBounds( _left , _top , _right , _bottom ) ;
_circle.Fill.Color := $FFFF0000 ;
_circle.Stroke.Kind := TBrushKind.bkNone ;
Form1.EndUpdate ;
end ;
end.