DrawString | 文字列を描画する | |
DrawFormatString |
書式付き文字列を描画する | |
SetFontSize | 描画する文字列のフォントのサイズをセットする | |
SetFontThickness | 描画する文字列の文字の太さをセットする |
宣言 | int DrawString( int x , int y , char *String , int Color ) ; |
概略 | 文字列を描画する |
引数 | x , y : 文字列を描画する領域の左上の座標 String : 描画する文字列のポインタ Color : 描画する文字列の色 |
戻り値 | 0:成功 −1:エラー発生 |
解説 | ( x , y )が示す座標にStringポインタが示している文字列を Color色で描画します。 |
#include "DxLib.h" int WINAPI WinMain(DXLIB) { DxLib_Init(); DrawString( 150, 100, "Hello C", GetColor(255,255,255)); WaitKey() ; DxLib_End() ; return 0 ; } |
宣言 | int DrawFormatString( int x , int y , int Color , char *FormatString , ... ) ; |
概略 | 書式付き文字列を描画する |
引数 | int x , y : 文字列を描画する起点座標 int Color : 描画する文字列の色 char *FormatString : 描画したい書式付き文字列のアドレス ... : 書式付き文字列に付随する引数 |
戻り値 | 0:成功 −1:エラー発生 |
解説 | 書式を指定することにより容易に数値変数や文字列配列の内容を画面に出力します。 printf関数に準拠しており、文字、文字列、整数、浮動小数の表示が可能です。 |
【文字列を描画する例】 %s char str[] = "晴れ" ; DrawFormatString( 0, 0, GetColor(255,255,255), "今日の天気は %s です", str ); 【int型整数値を描画する例】 %d int a=123,b=987; DrawFormatString( 0, 0, GetColor(255,255,255), "a=%d b=%d", a, b ); 【float型浮動小数点数値を描画する例】 %f float a=123.4f; |
宣言 | int SetFontSize( int FontSize ) ; |
概略 | 描画する文字列のフォントのサイズをセットする |
引数 | FontSize : 描画するフォントのサイズ(およそドット単位) |
戻り値 | 0:成功 −1:エラー発生 |
解説 | DrawString関数で描画する文字列の文字の大きさを設定します。 フォントのサイズは FontSize で指定したドット数にほぼ比例します。 |
#include "DxLib.h" int WINAPI WinMain(DXLIB) { DxLib_Init(); SetFontSize(64); DrawString( 150, 100, "Hello C", GetColor(255,255,255)); WaitKey() ; DxLib_End() ; return 0 ; } |
宣言 | int SetFontThickness( int TinckPal ) ; |
概略 | 描画する文字列の文字の太さをセットする |
引数 | TinckPal : 文字の太さ( 0 〜 9 ) |
戻り値 | 0:成功 −1:エラー発生 |
解説 | 『DrawString』関数で描画する文字列の太さを引数 TinckPal
が示す太さに変更します。 デフォルトでは 6 になっています。 因みにフォントの関係上、1や2の太さの違いでは見た目に影響が 出ない場合があります。 |
#include "DxLib.h" int WINAPI WinMain(DXLIB) { DxLib_Init(); SetFontThickness(10); DrawString( 150, 100, "Hello C", GetColor(255,255,255)); WaitKey() ; DxLib_End() ; return 0 ; } |