SDXFrameWork 0.07 SDXFrameWork

- メインページ
- 関連ページ
- クラス

全て クラス ネームスペース 関数 変数 列挙型 列挙型の値 ページ
BmpFont.h
1 #pragma once//☀SDXFramework
2 #include <Multimedia/Image.h>
3 #include <Framework/Anime.h>
4 #include <Multimedia/Font.h>
5 #include <Multimedia/Screen.h>
6
7 namespace SDX
8 {
11 class BmpFont : public IFont
12 {
13 private:
14 ImagePack *divImageNumber;
15 ImagePack *divImageAlphabetCapital;
16 ImagePack *divImageAlphabetLow;
17
18 bool isNumber;
19 bool isAlphabetCapital;
20 bool isAlphabetLow;
21 int numberHeight;
22 int numberWidth;
23
24 int alphabetCapitalHeight;
25 int alphabetCapitalWidth;
26
27 int alphabetLowHeight;
28 int alphabetLowWidth;
29
30 int maxHeight;
31
32 int enterSpace;
33
34 int spaceWidth;
35 public:
36 BmpFont():
37 isNumber(false),
38 isAlphabetCapital(false),
39 isAlphabetLow(false),
40 enterSpace(0)
41 {}
42
43 ~BmpFont(){};
44
46 int GetEnterHeight() const
47 {
48 return this->enterSpace;
49 }
50
53 void SetEnterHeight(int 改行の高さ)
54 {
55 this->enterSpace = 改行の高さ;
56 }
57
61 bool SetNumber( ImagePack* 数字用イメージ )
62 {
63 if( 数字用イメージ->GetSize() < 10 ) return false;
64
65 divImageNumber = 数字用イメージ;
66
67 numberWidth = 数字用イメージ->GetWidth();
68 numberHeight = 数字用イメージ->GetHeight();
69 spaceWidth = 数字用イメージ->GetWidth();
70
71 maxHeight = std::max( maxHeight , 数字用イメージ->GetHeight() );
72 isNumber = true;
73
74 return true;
75 }
76
80 bool SetAlphabetCapital(ImagePack* 大文字用イメージ )
81 {
82 if( 大文字用イメージ->GetSize() < 26 ) return false;
83
84 this->divImageAlphabetCapital = 大文字用イメージ;
85
86 this->alphabetCapitalWidth = 大文字用イメージ->GetWidth();
87 this->alphabetCapitalHeight = 大文字用イメージ->GetHeight();
88 this->spaceWidth = 大文字用イメージ->GetWidth();
89
90 this->maxHeight = std::max(this->maxHeight, 大文字用イメージ->GetHeight());
91
92 this->isAlphabetCapital = true;
93
94 return true;
95 }
96
100 bool SetAlphabetLow(ImagePack* 小文字用イメージ )
101 {
102 if( 小文字用イメージ->GetSize() < 26 ) return false;
103
104 divImageAlphabetLow = 小文字用イメージ;
105
106 alphabetLowWidth = 小文字用イメージ->GetWidth();
107 alphabetLowHeight = 小文字用イメージ->GetHeight();
108 spaceWidth = 小文字用イメージ->GetWidth();
109
110 maxHeight = std::max( maxHeight, 小文字用イメージ->GetHeight());
111
112 isAlphabetLow = true;
113 return true;
114 }
115
117 bool Draw(int X座標 , int Y座標 , Color 描画色 , VariadicStream 描画する文字列 ) const
118 {
119 Screen::SetBright(描画色);
120
121
122 for (auto it : 描画する文字列.StringS)
123 {
124 int i = 0;
125 int addX = 0;
126 int addY = this->maxHeight;
127 const char* bufstr = it.c_str();
128
129 while ( bufstr[i] != 0)//終端なら終了
130 {
131 if (bufstr[i] >= '0' && bufstr[i] <= '9' && this->isNumber)
132 {
133 divImageNumber[0][bufstr[i] - '0']->DrawExtend(
134 X座標 + addX,
135 Y座標 + addY - this->numberHeight,
136 X座標 + addX + this->numberWidth,
137 Y座標 + addY);
138
139 addX += this->numberWidth;
140 }
141 else if (bufstr[i] >= 'A' && bufstr[i] <= 'Z' && this->isAlphabetCapital)
142 {
143
144 divImageAlphabetCapital[0][bufstr[i] - 'A']->DrawExtend
145 (
146 X座標 + addX,
147 Y座標 + addY - this->alphabetCapitalHeight,
148 X座標 + addX + this->alphabetCapitalWidth,
149 Y座標 + addY
150 );
151
152 addX += this->alphabetCapitalWidth;
153
154 }
155 else if (bufstr[i] >= 'a' && bufstr[i] <= 'z' && this->isAlphabetLow)
156 {
157
158 divImageAlphabetLow[0][bufstr[i] - 'a']->DrawExtend
159 (
160 X座標 + addX,
161 Y座標 + addY - this->numberHeight,
162 X座標 + addX + this->numberWidth,
163 Y座標 + addY
164 );
165
166 addX += this->alphabetLowWidth;
167
168 }
169 else if ( bufstr[i] == ' ')
170 {
171 addX += spaceWidth;
172 }
173 ++i;
174 if (i == strlen( bufstr )) break;
175 }
176 addY += maxHeight + enterSpace;
177 }
178
179 Screen::SetBright(Color::White);
180 return true;
181 }
182 bool ZMask(int X座標, int Y座標, ZMaskType Zマスクタイプ, VariadicStream 描画する文字列) const
183 {
184 for (auto it : 描画する文字列.StringS)
185 {
186 int i = 0;
187 int addX = 0;
188 int addY = this->maxHeight;
189 const char* bufstr = it.c_str();
190
191 while (bufstr[i] != 0)
192 {
193 if (bufstr[i] >= '0' && bufstr[i] <= '9' && this->isNumber)
194 {
195 this->divImageNumber[0][bufstr[i] - '0']->ZMaskExtend
196 (
197 X座標 + addX,
198 Y座標 + addY - this->numberHeight,
199 X座標 + addX + this->numberWidth,
200 Y座標 + addY,
201 Zマスクタイプ
202 );
203 addX += this->numberWidth;
204 }
205 else if (bufstr[i] >= 'A' && bufstr[i] <= 'Z' && this->isAlphabetCapital)
206 {
207
208 this->divImageAlphabetCapital[0][bufstr[i] - 'A']->ZMaskExtend
209 (
210 X座標 + addX,
211 Y座標 + addY - this->alphabetCapitalHeight,
212 X座標 + addX + this->alphabetCapitalWidth,
213 Y座標 + addY,
214 Zマスクタイプ
215 );
216
217 addX += this->alphabetCapitalWidth;
218
219 }
220 else if (bufstr[i] >= 'a' && bufstr[i] <= 'z' && this->isAlphabetLow)
221 {
222
223 this->divImageAlphabetLow[0][bufstr[i] - 'a']->ZMaskExtend
224 (
225 X座標 + addX,
226 Y座標 + addY - this->numberHeight,
227 X座標 + addX + this->numberWidth,
228 Y座標 + addY,
229 Zマスクタイプ
230 );
231
232 addX += this->alphabetLowWidth;
233
234 }
235 else if (bufstr[i] == ' ')
236 {
237 addX += this->spaceWidth;
238 }
239 ++i;
240 if (i == strlen(bufstr)) break;
241 }
242 addY += this->maxHeight + this->enterSpace;
243 }
244 return true;
245 }
246
248 bool DrawRotate(int X座標, int Y座標, double 拡大率, double 角度, Color 描画色, bool 反転フラグ, VariadicStream 描画する文字列) const
249 {
250 return false;
251 }
253 bool ZMaskRotate(int X座標, int Y座標, double 拡大率, double 角度, ZMaskType Zマスクタイプ, bool 反転フラグ, VariadicStream 描画する文字列) const
254 {
255 return false;
256 }
257
259 bool DrawExtend(int X座標, int Y座標, double X拡大率, double Y拡大率, Color 描画色, VariadicStream 描画する文字列) const
260 {
261 for (auto it : 描画する文字列.StringS)
262 {
263 int i = 0;
264 int addX = 0;
265 int addY = this->maxHeight;
266 const char* bufstr = it.c_str();
267
268 Screen::SetBright(描画色);
269
270 while (bufstr[i] != 0)
271 {
272 if (bufstr[i] >= '0' && bufstr[i] <= '9' && this->isNumber)
273 {
274
275 this->divImageNumber[0][bufstr[i] - '0']->DrawExtend
276 (
277 X座標 + int(addX * X拡大率),
278 Y座標 + int((addY - this->numberHeight) * Y拡大率),
279 X座標 + int((addX + this->numberWidth) * X拡大率),
280 Y座標 + int(addY * Y拡大率)
281 );
282
283 addX += this->numberWidth;
284
285 }
286 else if (bufstr[i] >= 'A' && bufstr[i] <= 'Z' && this->isAlphabetCapital)
287 {
288
289 this->divImageAlphabetCapital[0][bufstr[i] - 'A']->DrawExtend
290 (
291 X座標 + int(addX * X拡大率),
292 Y座標 + int((addY - this->alphabetCapitalHeight) * Y拡大率),
293 X座標 + int((addX + this->alphabetCapitalWidth) * X拡大率),
294 Y座標 + int(addY * Y拡大率)
295 );
296
297 addX += this->alphabetCapitalWidth;
298
299 }
300 else if (bufstr[i] >= 'a' && bufstr[i] <= 'z' && this->isAlphabetLow)
301 {
302 this->divImageAlphabetLow[0][bufstr[i] - 'a']->DrawExtend
303 (
304 X座標 + int(addX * X拡大率),
305 Y座標 + int((addY - this->alphabetLowHeight) * Y拡大率),
306 X座標 + int((addX + this->alphabetLowWidth) * X拡大率),
307 Y座標 + int(addY * Y拡大率)
308 );
309
310 addX += this->alphabetLowWidth;
311 }
312 else if (bufstr[i] == ' ')
313 {
314 addX += this->spaceWidth;
315 }
316 ++i;
317 if (i == strlen(bufstr)) break;
318 }
319 addY += this->maxHeight + this->enterSpace;
320 }
321
322 Screen::SetBright(Color::White);
323
324 return true;
325 }
326 bool ZMaskExtend(int X座標, int Y座標, double X拡大率, double Y拡大率, ZMaskType Zマスクタイプ, VariadicStream 描画する文字列) const
327 {
328 for (auto it : 描画する文字列.StringS)
329 {
330 int i = 0;
331 int addX = 0;
332 int addY = this->maxHeight;
333 const char* bufstr = it.c_str();
334
335 while (bufstr[i] != 0)
336 {
337 if (bufstr[i] >= '0' && bufstr[i] <= '9' && this->isNumber)
338 {
339
340 this->divImageNumber[0][bufstr[i] - '0']->ZMaskExtend
341 (
342 X座標 + int(addX * X拡大率),
343 Y座標 + int((addY - this->numberHeight) * Y拡大率),
344 X座標 + int((addX + this->numberWidth) * X拡大率),
345 Y座標 + int(addY * Y拡大率),
346 Zマスクタイプ
347 );
348
349 addX += this->numberWidth;
350
351 }
352 else if (bufstr[i] >= 'A' && bufstr[i] <= 'Z' && this->isAlphabetCapital)
353 {
354
355 this->divImageAlphabetCapital[0][bufstr[i] - 'A']->ZMaskExtend
356 (
357 X座標 + int(addX * X拡大率),
358 Y座標 + int((addY - this->alphabetCapitalHeight) * Y拡大率),
359 X座標 + int((addX + this->alphabetCapitalWidth) * X拡大率),
360 Y座標 + int(addY * Y拡大率),
361 Zマスクタイプ
362 );
363
364 addX += this->alphabetCapitalWidth;
365
366 }
367 else if (bufstr[i] >= 'a' && bufstr[i] <= 'z' && this->isAlphabetLow)
368 {
369 this->divImageAlphabetLow[0][bufstr[i] - 'a']->ZMaskExtend
370 (
371 X座標 + int(addX * X拡大率),
372 Y座標 + int((addY - this->alphabetLowHeight) * Y拡大率),
373 X座標 + int((addX + this->alphabetLowWidth) * X拡大率),
374 Y座標 + int(addY * Y拡大率),
375 Zマスクタイプ
376 );
377
378 addX += this->alphabetLowWidth;
379 }
380 else if (bufstr[i] == ' ')
381 {
382 addX += this->spaceWidth;
383 }
384 ++i;
385 if (i == strlen(bufstr)) break;
386 }
387 addY += this->maxHeight + this->enterSpace;
388 }
389 return true;
390 }
391
392 };
393 }
SDX::ZMaskType
ZMaskType
Zマスクの種類.
Definition: Image.h:8
SDX::IFont
Font,BmpFont等のインターフェース.
Definition: IFont.h:9
SDX::ImagePack::GetWidth
int GetWidth() const
最大幅を取得.
Definition: ImagePack.h:107
SDX::Screen::SetBright
static bool SetBright(Color 輝度)
描画輝度を設定.
Definition: Screen.h:153
SDX::BmpFont
ビットマップフォントを表すクラス.
Definition: BmpFont.h:11
SDX::BmpFont::SetNumber
bool SetNumber(ImagePack *数字用イメージ)
数字フォントを設定.
Definition: BmpFont.h:61
SDX::BmpFont::SetAlphabetCapital
bool SetAlphabetCapital(ImagePack *大文字用イメージ)
英大文字フォントをセット.
Definition: BmpFont.h:80
SDX::BmpFont::Draw
bool Draw(int X座標, int Y座標, Color 描画色, VariadicStream 描画する文字列) const
書式付きで文字を描画.
Definition: BmpFont.h:117
SDX::Color
色を表すクラス.
Definition: Color.h:7
SDX::ImagePack::GetSize
int GetSize() const
要素数を取得.
Definition: ImagePack.h:101
SDX::VariadicStream
可変数引数な文字列を処理するクラス.
Definition: VariadicStream.h:8
SDX::ImagePack::GetHeight
int GetHeight() const
最大高さを取得.
Definition: ImagePack.h:113
SDX::BmpFont::ZMaskRotate
bool ZMaskRotate(int X座標, int Y座標, double 拡大率, double 角度, ZMaskType Zマスクタイプ, bool 反転フラグ, VariadicStream 描画する文字列) const
文字を回転してマスク[未実装].
Definition: BmpFont.h:253
SDX::BmpFont::SetAlphabetLow
bool SetAlphabetLow(ImagePack *小文字用イメージ)
英小文字フォントをセット.
Definition: BmpFont.h:100
SDX::ImagePack
複数のImageをまとめるクラス.
Definition: ImagePack.h:9
SDX::BmpFont::ZMaskExtend
bool ZMaskExtend(int X座標, int Y座標, double X拡大率, double Y拡大率, ZMaskType Zマスクタイプ, VariadicStream 描画する文字列) const
拡大率を指定して文字をマスク[DXLIB].
Definition: BmpFont.h:326
SDX::BmpFont::DrawExtend
bool DrawExtend(int X座標, int Y座標, double X拡大率, double Y拡大率, Color 描画色, VariadicStream 描画する文字列) const
拡大率を指定して文字を描画.
Definition: BmpFont.h:259
SDX::BmpFont::ZMask
bool ZMask(int X座標, int Y座標, ZMaskType Zマスクタイプ, VariadicStream 描画する文字列) const
文字をマスク[DXLIB].
Definition: BmpFont.h:182
SDX::BmpFont::DrawRotate
bool DrawRotate(int X座標, int Y座標, double 拡大率, double 角度, Color 描画色, bool 反転フラグ, VariadicStream 描画する文字列) const
文字を回転して描画[未実装].
Definition: BmpFont.h:248
SDX::BmpFont::GetEnterHeight
int GetEnterHeight() const
改行の高さを取得.
Definition: BmpFont.h:46
SDX::BmpFont::SetEnterHeight
void SetEnterHeight(int 改行の高さ)
改行の高さを設定.
Definition: BmpFont.h:53