![]() ![]() ![]()
|
SophiaFramework 2.1 |
SophiaFramework では画面描画を行いやすくするために SFBGraphics と SFBDisplay クラスを抽象化した SFUGraphics クラスが用意されています。SFUGraphics クラスは SFBGraphics クラスの図形描画関数と SFBDisplay の文字描画関数を継承しており、 クリッピングや原点移動などを抽象的に扱うことができます。
たとえば、画面に四角形を描画するためには以下のように記述します。
SFUGraphicsPtr g; SFURect r(0,0,10,10); g = SFUGraphics::Instance(); g->SetColor(SFUColor(0x00,0x00,0x00)); g->SetFillMode(FALSE); g->DrawRect(r);
また、文字を描画するには以下のように記述します。
SFUGraphicsPtr g;
SFURect r(0,0,100,20);
g = SFUGraphics::Instance();
g->SetColor(SFUColor(0x00,0x00,0x00));
g->DrawText("hello world.",r);
文字描画では長い文字列を自動改行して描画する関数も用意されています。 下記サンプル コードでは、この関数を使用して全画面に文章を描画しています。
SFUGraphicsPtr g;
SFURect r(0,0,SFUGraphics::DeviceSize());
g = SFUGraphics::Instance();
g->SetColor(SFUColor(0x00,0x00,0x00));
g->DrawString("Ladies and Gentleman, SophiaFramework version 2 is "
"the most powerful frameowk library in the BREW world.",
r, IDF_ALIGN_LEFT);
原点移動を行うには以下のように記述します。 下記のサンプル コードでは、画面の左上の座標を (-10,-10) と設定してから描画を 行っています。左上の座標を (-10,-10) に設定するということは、原点は設定前の 座標で表すと (10,10) に移動したことになります。
SFUGraphicsPtr g;
SFURect r(0,0,100,20);
g = SFUGraphics::Instance();
g->SetTranslate(SFUPoint(-10,-10));
g->SetColor(SFUColor(0x00,0x00,0x00));
g->SetFillMode(FALSE);
g->DrawRect(r);
g->DrawText("hello world",r);
| Copyright(C) 2003 Sophia Cradle Inc., All Rights Reserved. |
![]() ![]() ![]()
|