2 #include <Multimedia/Image.h>
3 #include <Framework/Anime.h>
4 #include <Multimedia/Font.h>
5 #include <Multimedia/Screen.h>
10 class BmpFont :
public IFont
14 ImagePack *divImageNumber;
15 ImagePack *divImageAlphabetCapital;
16 ImagePack *divImageAlphabetLow;
19 bool isAlphabetCapital;
24 int alphabetCapitalHeight;
25 int alphabetCapitalWidth;
27 int alphabetLowHeight;
38 isAlphabetCapital(false),
48 return this->enterSpace;
63 if( 数字用イメージ->GetSize() < 10 )
return false;
65 divImageNumber = 数字用イメージ;
67 numberWidth = 数字用イメージ->GetWidth();
68 numberHeight = 数字用イメージ->GetHeight();
69 spaceWidth = 数字用イメージ->GetWidth();
71 maxHeight = std::max( maxHeight , 数字用イメージ->GetHeight() );
82 if( 大文字用イメージ->GetSize() < 26 )
return false;
84 this->divImageAlphabetCapital = 大文字用イメージ;
86 this->alphabetCapitalWidth = 大文字用イメージ->GetWidth();
87 this->alphabetCapitalHeight = 大文字用イメージ->GetHeight();
88 this->spaceWidth = 大文字用イメージ->GetWidth();
90 this->maxHeight = std::max(this->maxHeight, 大文字用イメージ->GetHeight());
92 this->isAlphabetCapital =
true;
102 if( 小文字用イメージ->GetSize() < 26 )
return false;
104 divImageAlphabetLow = 小文字用イメージ;
106 alphabetLowWidth = 小文字用イメージ->GetWidth();
107 alphabetLowHeight = 小文字用イメージ->GetHeight();
108 spaceWidth = 小文字用イメージ->GetWidth();
110 maxHeight = std::max( maxHeight, 小文字用イメージ->GetHeight());
112 isAlphabetLow =
true;
117 bool Draw(
int X座標 ,
int Y座標 ,
Color 描画色 ,
const char *描画文字列 , ...)
const
121 va_start(args, 描画文字列);
122 vsprintf_s(bufstr, 1024, 描画文字列, args);
129 int addY = this->maxHeight;
131 while( bufstr[i] != NULL)
133 if( bufstr[i] >=
'0' && bufstr[i] <=
'9' && this->isNumber)
135 divImageNumber[0][ bufstr[i] -
'0' ]->DrawExtend(
137 Y座標 + addY - this->numberHeight,
138 X座標 + addX + this->numberWidth,
141 addX += this->numberWidth;
143 else if (bufstr[i] >=
'A' && bufstr[i] <=
'Z' && this->isAlphabetCapital)
146 divImageAlphabetCapital[0][ bufstr[i] -
'A' ]->DrawExtend
149 Y座標 + addY - this->alphabetCapitalHeight,
150 X座標 + addX + this->alphabetCapitalWidth,
154 addX += this->alphabetCapitalWidth;
157 else if (bufstr[i] >=
'a' && bufstr[i] <=
'z' && this->isAlphabetLow)
160 divImageAlphabetLow[0][ bufstr[i] -
'a']->DrawExtend
163 Y座標 + addY - this->numberHeight,
164 X座標 + addX + this->numberWidth,
168 addX += this->alphabetLowWidth;
171 else if (bufstr[i] ==
' ')
175 else if (bufstr[i] ==
'\\' && bufstr[i+1] ==
'n' )
177 addY += maxHeight + enterSpace;
180 if(i == strlen(bufstr) )
break;
186 bool ZMask(
int X座標,
int Y座標, ZMaskType Zマスクタイプ,
const char *描画文字列, ...)
const
190 va_start(args, 描画文字列);
191 vsprintf_s(bufstr, 1024, 描画文字列, args);
196 int addY = this->maxHeight;
198 while( bufstr[i] != NULL)
200 if( bufstr[i] >=
'0' && bufstr[i] <=
'9' && this->isNumber)
202 this->divImageNumber[0][ bufstr[i] -
'0' ]->ZMaskExtend
205 Y座標 + addY - this->numberHeight,
206 X座標 + addX + this->numberWidth,
210 addX += this->numberWidth;
212 else if (bufstr[i] >=
'A' && bufstr[i] <=
'Z' && this->isAlphabetCapital)
215 this->divImageAlphabetCapital[0][ bufstr[i] -
'A' ]->ZMaskExtend
218 Y座標 + addY - this->alphabetCapitalHeight,
219 X座標 + addX + this->alphabetCapitalWidth,
224 addX += this->alphabetCapitalWidth;
227 else if (bufstr[i] >=
'a' && bufstr[i] <=
'z' && this->isAlphabetLow)
230 this->divImageAlphabetLow[0][ bufstr[i] -
'a']->ZMaskExtend
233 Y座標 + addY - this->numberHeight,
234 X座標 + addX + this->numberWidth ,
239 addX += this->alphabetLowWidth;
242 else if (bufstr[i] ==
' ')
244 addX += this->spaceWidth;
246 else if (bufstr[i] ==
'\\' && bufstr[i+1] ==
'n' )
248 addY += this->maxHeight + this->enterSpace;
251 if(i == strlen(bufstr) )
break;
257 bool DrawExtend(
int X座標,
int Y座標,
double X拡大率,
double Y拡大率,
Color 描画色,
const char *描画文字列, ...)
const
261 va_start(args, 描画文字列);
262 vsprintf_s(bufstr, 1024, 描画文字列, args);
267 double addY = this->maxHeight;
271 while( bufstr[i] != NULL)
273 if( bufstr[i] >=
'0' && bufstr[i] <=
'9' && this->isNumber)
276 this->divImageNumber[0][bufstr[i] -
'0' ]->DrawExtend
278 X座標 +
int(addX * X拡大率),
279 Y座標 +
int((addY - this->numberHeight) * Y拡大率),
280 X座標 +
int((addX + this->numberWidth) * X拡大率),
281 Y座標 +
int(addY * Y拡大率)
284 addX += this->numberWidth;
287 else if (bufstr[i] >=
'A' && bufstr[i] <=
'Z' && this->isAlphabetCapital)
290 this->divImageAlphabetCapital[0][ bufstr[i] -
'A' ]->DrawExtend
292 X座標 +
int(addX * X拡大率),
293 Y座標 +
int((addY - this->alphabetCapitalHeight) * Y拡大率),
294 X座標 +
int((addX + this->alphabetCapitalWidth) * X拡大率),
295 Y座標 +
int(addY * Y拡大率)
298 addX += this->alphabetCapitalWidth;
301 else if (bufstr[i] >=
'a' && bufstr[i] <=
'z' && this->isAlphabetLow)
303 this->divImageAlphabetLow[0][ bufstr[i] -
'a']->DrawExtend
305 X座標 +
int(addX * X拡大率),
306 Y座標 +
int((addY - this->alphabetLowHeight) * Y拡大率),
307 X座標 +
int((addX + this->alphabetLowWidth) * X拡大率),
308 Y座標 +
int(addY * Y拡大率)
311 addX += this->alphabetLowWidth;
313 else if (bufstr[i] ==
' ')
315 addX += this->spaceWidth;
317 else if (bufstr[i] ==
'\\' && bufstr[i+1] ==
'n' )
319 addY += this->maxHeight + this->enterSpace;
322 if(i == strlen(bufstr) )
break;
329 bool ZMaskExtend(
int X座標,
int Y座標,
double X拡大率,
double Y拡大率, ZMaskType Zマスクタイプ,
const char *描画文字列, ...)
const
333 va_start(args, 描画文字列);
334 vsprintf_s(bufstr, 1024, 描画文字列, args);
339 double addY = this->maxHeight;
341 while( bufstr[i] != NULL)
343 if( bufstr[i] >=
'0' && bufstr[i] <=
'9' && this->isNumber)
346 this->divImageNumber[0][bufstr[i] -
'0' ]->ZMaskExtend
348 X座標 +
int(addX * X拡大率),
349 Y座標 +
int((addY - this->numberHeight) * Y拡大率),
350 X座標 +
int((addX + this->numberWidth) * X拡大率),
351 Y座標 +
int(addY * Y拡大率),
355 addX += this->numberWidth;
358 else if (bufstr[i] >=
'A' && bufstr[i] <=
'Z' && this->isAlphabetCapital)
361 this->divImageAlphabetCapital[0][ bufstr[i] -
'A' ]->ZMaskExtend
363 X座標 +
int(addX * X拡大率),
364 Y座標 +
int((addY - this->alphabetCapitalHeight) * Y拡大率),
365 X座標 +
int((addX + this->alphabetCapitalWidth) * X拡大率),
366 Y座標 +
int(addY * Y拡大率),
370 addX += this->alphabetCapitalWidth;
373 else if (bufstr[i] >=
'a' && bufstr[i] <=
'z' && this->isAlphabetLow)
375 this->divImageAlphabetLow[0][ bufstr[i] -
'a']->ZMaskExtend
377 X座標 +
int(addX * X拡大率),
378 Y座標 +
int((addY - this->alphabetLowHeight) * Y拡大率),
379 X座標 +
int((addX + this->alphabetLowWidth) * X拡大率),
380 Y座標 +
int(addY * Y拡大率),
384 addX += this->alphabetLowWidth;
386 else if (bufstr[i] ==
' ')
388 addX += this->spaceWidth;
390 else if (bufstr[i] ==
'\\' && bufstr[i+1] ==
'n' )
392 addY += this->maxHeight + this->enterSpace;
395 if(i == strlen(bufstr) )
break;
static bool SetBright(Color 輝度)
描画輝度を設定.
Definition: Screen.h:211
bool SetNumber(ImagePack *数字用イメージ)
数字フォントを設定.
Definition: BmpFont.h:61
bool SetAlphabetCapital(ImagePack *大文字用イメージ)
英大文字フォントをセット.
Definition: BmpFont.h:80
色を表すクラス.
Definition: Color.h:7
void SetEnterHeight(int height)
改行の高さを設定.
Definition: BmpFont.h:53
bool SetAlphabetLow(ImagePack *小文字用イメージ)
英小文字フォントをセット.
Definition: BmpFont.h:100
int GetEnterHeight() const
改行の高さを取得.
Definition: BmpFont.h:46
bool DrawExtend(int X座標, int Y座標, double X拡大率, double Y拡大率, Color 描画色, const char *描画文字列,...) const
拡大率を指定して文字を描画.
Definition: BmpFont.h:257
bool Draw(int X座標, int Y座標, Color 描画色, const char *描画文字列,...) const
書式付きで文字を描画.
Definition: BmpFont.h:117