-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconsole_draw_basic.html
More file actions
429 lines (426 loc) · 22.7 KB
/
console_draw_basic.html
File metadata and controls
429 lines (426 loc) · 22.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-C2YXLNQ21C"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-C2YXLNQ21C');
</script>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>libtcod documentation | Basic printing functions</title>
<script type="text/javascript" src="../js/doctcod.js"></script>
<link href="../css/style.css" rel="stylesheet" type="text/css">
</head>
<link type="text/css" rel="stylesheet" href="../css/shCore.css">
</link>
<link type="text/css" rel="stylesheet" href="../css/shThemeDefault.css">
</link>
<script language="javascript" src="../js/shCore.js"></script>
<script language="javascript" src="../js/shBrushBash.js"></script>
<body>
<div class="header">
<p><span class="title1">libtcod</span><span class="title2">documentation</span></p>
</div>
<div class="breadcrumb">
<div class="breadcrumbtext">
<p>
you are here: <a onclick="link('../index2.html')">Index</a> > <a onclick="link('console.html')">2.
Console</a> > <a onclick="link('console_draw.html')">2.2. Drawing on the root console</a> > <a
onclick="link('console_draw_basic.html')">2.2.1. Basic printing functions</a><br>
<a class="next" onclick="link('console_bkgnd_flag_t.html')">2.2.2. Background effect flags</a>
</p>
</div>
</div>
<div class="filter"><input type="checkbox" id="chk_c" name="chk_c" onchange="enable('c',this.checked)"
checked='checked'><label for='chk_c'> C </label><input type="checkbox" id="chk_cpp" name="chk_cpp"
onchange="enable('cpp',this.checked)" checked='checked'><label for='chk_cpp'> C++ </label><input type="checkbox"
id="chk_py" name="chk_py" onchange="enable('py',this.checked)" checked='checked'><label for='chk_py'> Py
</label><input type="checkbox" id="chk_lua" name="chk_lua" onchange="enable('lua',this.checked)"
disabled='disabled'><label class='disabled' for='chk_lua'> Lua </label><input type="checkbox" id="chk_cs"
name="chk_cs" onchange="enable('cs',this.checked)" disabled='disabled'><label class='disabled' for='chk_cs'> C#
</label></div>
<div class="main">
<div class="maintext">
<h1>2.2.1. Basic printing functions</h1>
<div id="toc">
<ul>
<li><a href="#0">Setting the default background color</a></li>
<li><a href="#1">Setting the default foreground color</a></li>
<li><a href="#2">Clearing a console</a></li>
<li><a href="#3">Setting the background color of a cell</a></li>
<li><a href="#4">Setting the foreground color of a cell</a></li>
<li><a href="#5">Setting the ASCII code of a cell</a></li>
<li><a href="#6">Setting every property of a cell using default colors</a></li>
<li><a href="#7">Setting every property of a cell using specific colors</a></li>
</ul>
</div>
<a name="0"></a>
<h3>Setting the default background color</h3>
<p>This function changes the default background color for a console. The default background color is used by
several drawing functions like clear, putChar, ...<br /> </p>
<div class="code">
<p class="cpp"><span class="code-keyword">void</span> TCODConsole<span
class="code-symbol">::</span>setDefaultBackground<span class="code-symbol">(</span>TCODColor back<span
class="code-symbol">)</span></p>
<p class="c"><span class="code-keyword">void</span> TCOD_console_set_default_background<span
class="code-symbol">(</span><span class="code-tcod">TCOD_console_t</span> con<span
class="code-symbol">,</span><span class="code-tcod">TCOD_color_t</span> back<span
class="code-symbol">)</span></p>
<p class="py">console_set_default_background<span class="code-symbol">(</span>con<span
class="code-symbol">,</span>back<span class="code-symbol">)</span></p>
</div>
<table class="param">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr class="hilite">
<td>con</td>
<td>in the C and Python versions, the offscreen console handler or NULL for the root console<br /> </td>
</tr>
<tr>
<td>back</td>
<td>the new default background color for this console<br /> </td>
</tr>
</tbody>
</table>
<h6>Example:</h6>
<div class="code">
<p class="cpp">TCODConsole<span class="code-symbol">::</span>root<span
class="code-symbol">-></span>setDefaultBackground<span class="code-symbol">(</span>myColor<span
class="code-symbol">)</span></p>
<p class="c">TCOD_console_set_default_background<span class="code-symbol">(</span><span
class="code-tcod">NULL</span><span class="code-symbol">,</span> my_color<span class="code-symbol">)</span>
</p>
<p class="py">litbcod<span class="code-symbol">.</span>console_set_default_background<span
class="code-symbol">(</span><span class="code-value">0</span><span class="code-symbol">,</span>
my_color<span class="code-symbol">)</span></p>
</div>
<hr>
<a name="1"></a>
<h3>Setting the default foreground color</h3>
<p>This function changes the default foreground color for a console. The default foreground color is used by
several drawing functions like clear, putChar, ...<br /> </p>
<div class="code">
<p class="cpp"><span class="code-keyword">void</span> TCODConsole<span
class="code-symbol">::</span>setDefaultForeground<span class="code-symbol">(</span>TCODColor fore<span
class="code-symbol">)</span></p>
<p class="c"><span class="code-keyword">void</span> TCOD_console_set_default_foreground<span
class="code-symbol">(</span><span class="code-tcod">TCOD_console_t</span> con<span
class="code-symbol">,</span><span class="code-tcod">TCOD_color_t</span> fore<span
class="code-symbol">)</span></p>
<p class="py">console_set_default_foreground<span class="code-symbol">(</span>con<span
class="code-symbol">,</span> fore<span class="code-symbol">)</span></p>
</div>
<table class="param">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr class="hilite">
<td>con</td>
<td>in the C and Python versions, the offscreen console handler or NULL for the root console<br /> </td>
</tr>
<tr>
<td>fore</td>
<td>the new default foreground color for this console<br /> </td>
</tr>
</tbody>
</table>
<h6>Example:</h6>
<div class="code">
<p class="cpp">TCODConsole<span class="code-symbol">::</span>root<span
class="code-symbol">-></span>setDefaultForeground<span class="code-symbol">(</span>myColor<span
class="code-symbol">)</span></p>
<p class="c">TCOD_console_set_default_foreground<span class="code-symbol">(</span><span
class="code-tcod">NULL</span><span class="code-symbol">,</span> my_color<span class="code-symbol">)</span>
</p>
<p class="py">litbcod<span class="code-symbol">.</span>console_set_default_foreground<span
class="code-symbol">(</span><span class="code-value">0</span><span class="code-symbol">,</span>
my_color<span class="code-symbol">)</span></p>
</div>
<hr>
<a name="2"></a>
<h3>Clearing a console</h3>
<p>This function modifies all cells of a console :<br /> * set the cell's background color to the console default
background color<br /> * set the cell's foreground color to the console default foreground color<br /> * set the
cell's ASCII code to 32 (space)<br /> </p>
<div class="code">
<p class="cpp"><span class="code-keyword">void</span> TCODConsole<span class="code-symbol">::</span>clear<span
class="code-symbol">(</span><span class="code-symbol">)</span></p>
<p class="c"><span class="code-keyword">void</span> TCOD_console_clear<span class="code-symbol">(</span><span
class="code-tcod">TCOD_console_t</span> con<span class="code-symbol">)</span></p>
<p class="py">console_clear<span class="code-symbol">(</span>con<span class="code-symbol">)</span></p>
</div>
<table class="param">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr class="hilite">
<td>con</td>
<td>in the C and Python versions, the offscreen console handler or NULL for the root console<br /> </td>
</tr>
</tbody>
</table><a name="3"></a>
<h3>Setting the background color of a cell</h3>
<p>This function modifies the background color of a cell, leaving other properties (foreground color and ASCII
code) unchanged.<br /> </p>
<div class="code">
<p class="cpp"><span class="code-keyword">void</span> TCODConsole<span
class="code-symbol">::</span>setCharBackground<span class="code-symbol">(</span><span
class="code-keyword">int</span> x<span class="code-symbol">,</span><span class="code-keyword"> int</span>
y<span class="code-symbol">,</span><span class="code-keyword"> const</span> TCODColor<span
class="code-symbol"> &</span>col<span class="code-symbol">,</span><span class="code-tcod">
TCOD_bkgnd_flag_t</span> flag<span class="code-symbol"> =</span><span class="code-tcod">
TCOD_BKGND_SET</span><span class="code-symbol">)</span></p>
<p class="c"><span class="code-keyword">void</span> TCOD_console_set_char_background<span
class="code-symbol">(</span><span class="code-tcod">TCOD_console_t</span> con<span
class="code-symbol">,</span><span class="code-keyword">int</span> x<span class="code-symbol">,</span><span
class="code-keyword"> int</span> y<span class="code-symbol">,</span><span class="code-tcod">
TCOD_color_t</span> col<span class="code-symbol">,</span><span class="code-tcod"> TCOD_bkgnd_flag_t</span>
flag<span class="code-symbol">)</span></p>
<p class="py">console_set_char_background<span class="code-symbol">(</span>con<span class="code-symbol">,</span>
x<span class="code-symbol">,</span> y<span class="code-symbol">,</span> col<span class="code-symbol">,</span>
flag<span class="code-symbol">=</span><span class="code-tcod">BKGND_SET</span><span
class="code-symbol">)</span></p>
</div>
<table class="param">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr class="hilite">
<td>con</td>
<td>in the C and Python versions, the offscreen console handler or NULL for the root console<br /> </td>
</tr>
<tr>
<td>x,y</td>
<td>coordinates of the cell in the console.<br /> 0
<= x < console width<br /> 0
<= y < console height<br />
</td>
</tr>
<tr class="hilite">
<td>col</td>
<td>the background color to use. You can use color constants<br /> </td>
</tr>
<tr>
<td>flag</td>
<td>this flag defines how the cell's background color is modified. See <a
href="console_bkgnd_flag_t.html">TCOD_bkgnd_flag_t</a><br /> </td>
</tr>
</tbody>
</table><a name="4"></a>
<h3>Setting the foreground color of a cell</h3>
<p>This function modifies the foreground color of a cell, leaving other properties (background color and ASCII
code) unchanged.<br /> </p>
<div class="code">
<p class="cpp"><span class="code-keyword">void</span> TCODConsole<span
class="code-symbol">::</span>setCharForeground<span class="code-symbol">(</span><span
class="code-keyword">int</span> x<span class="code-symbol">,</span><span class="code-keyword"> int</span>
y<span class="code-symbol">,</span><span class="code-keyword"> const</span> TCODColor<span
class="code-symbol"> &</span>col<span class="code-symbol">)</span></p>
<p class="c"><span class="code-keyword">void</span> TCOD_console_set_char_foreground<span
class="code-symbol">(</span><span class="code-tcod">TCOD_console_t</span> con<span
class="code-symbol">,</span><span class="code-keyword">int</span> x<span class="code-symbol">,</span><span
class="code-keyword"> int</span> y<span class="code-symbol">,</span><span class="code-tcod">
TCOD_color_t</span> col<span class="code-symbol">)</span></p>
<p class="py">console_set_char_foreground<span class="code-symbol">(</span>con<span class="code-symbol">,</span>
x<span class="code-symbol">,</span> y<span class="code-symbol">,</span> col<span class="code-symbol">)</span>
</p>
</div>
<table class="param">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr class="hilite">
<td>con</td>
<td>in the C and Python versions, the offscreen console handler or NULL for the root console<br /> </td>
</tr>
<tr>
<td>x,y</td>
<td>coordinates of the cell in the console.<br /> 0
<= x < console width<br /> 0
<= y < console height<br />
</td>
</tr>
<tr class="hilite">
<td>col</td>
<td>the foreground color to use. You can use color constants<br /> </td>
</tr>
</tbody>
</table><a name="5"></a>
<h3>Setting the ASCII code of a cell</h3>
<p>This function modifies the ASCII code of a cell, leaving other properties (background and foreground colors)
unchanged.<br /> Note that since a clear console has both background and foreground colors set to black for
every cell, using setchar will produce black characters on black background. Use putchar instead.<br /> </p>
<div class="code">
<p class="cpp"><span class="code-keyword">void</span> TCODConsole<span class="code-symbol">::</span>setChar<span
class="code-symbol">(</span><span class="code-keyword">int</span> x<span class="code-symbol">,</span><span
class="code-keyword"> int</span> y<span class="code-symbol">,</span><span class="code-keyword"> int</span>
c<span class="code-symbol">)</span></p>
<p class="c"><span class="code-keyword">void</span> TCOD_console_set_char<span class="code-symbol">(</span><span
class="code-tcod">TCOD_console_t</span> con<span class="code-symbol">,</span><span
class="code-keyword">int</span> x<span class="code-symbol">,</span><span class="code-keyword"> int</span>
y<span class="code-symbol">,</span><span class="code-keyword"> int</span> c<span class="code-symbol">)</span>
</p>
<p class="py">console_set_char<span class="code-symbol">(</span>con<span class="code-symbol">,</span> x<span
class="code-symbol">,</span> y<span class="code-symbol">,</span> c<span class="code-symbol">)</span></p>
</div>
<table class="param">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr class="hilite">
<td>con</td>
<td>in the C and Python versions, the offscreen console handler or NULL for the root console<br /> </td>
</tr>
<tr>
<td>x,y</td>
<td>coordinates of the cell in the console.<br /> 0
<= x < console width<br /> 0
<= y < console height<br />
</td>
</tr>
<tr class="hilite">
<td>c</td>
<td>the new ASCII code for the cell. You can use ASCII constants<br /> </td>
</tr>
</tbody>
</table><a name="6"></a>
<h3>Setting every property of a cell using default colors</h3>
<p>This function modifies every property of a cell :<br /> * update the cell's background color according to the
console default background color (see TCOD_bkgnd_flag_t).<br /> * set the cell's foreground color to the console
default foreground color<br /> * set the cell's ASCII code to c<br /> </p>
<div class="code">
<p class="cpp"><span class="code-keyword">void</span> TCODConsole<span class="code-symbol">::</span>putChar<span
class="code-symbol">(</span><span class="code-keyword">int</span> x<span class="code-symbol">,</span><span
class="code-keyword"> int</span> y<span class="code-symbol">,</span><span class="code-keyword"> int</span>
c<span class="code-symbol">,</span><span class="code-tcod"> TCOD_bkgnd_flag_t</span> flag<span
class="code-symbol"> =</span><span class="code-tcod"> TCOD_BKGND_DEFAULT</span><span
class="code-symbol">)</span></p>
<p class="c"><span class="code-keyword">void</span> TCOD_console_put_char<span class="code-symbol">(</span><span
class="code-tcod">TCOD_console_t</span> con<span class="code-symbol">,</span><span
class="code-keyword">int</span> x<span class="code-symbol">,</span><span class="code-keyword"> int</span>
y<span class="code-symbol">,</span><span class="code-keyword"> int</span> c<span
class="code-symbol">,</span><span class="code-tcod"> TCOD_bkgnd_flag_t</span> flag<span
class="code-symbol">)</span></p>
<p class="py">console_put_char<span class="code-symbol">(</span> con<span class="code-symbol">,</span> x<span
class="code-symbol">,</span> y<span class="code-symbol">,</span> c<span class="code-symbol">,</span>
flag<span class="code-symbol">=</span><span class="code-tcod">BKGND_DEFAULT</span><span
class="code-symbol">)</span></p>
</div>
<table class="param">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr class="hilite">
<td>con</td>
<td>in the C and Python versions, the offscreen console handler or NULL for the root console<br /> </td>
</tr>
<tr>
<td>x,y</td>
<td>coordinates of the cell in the console.<br /> 0
<= x < console width<br /> 0
<= y < console height<br />
</td>
</tr>
<tr class="hilite">
<td>c</td>
<td>the new ASCII code for the cell. You can use ASCII constants<br /> </td>
</tr>
<tr>
<td>flag</td>
<td>this flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t<br /> </td>
</tr>
</tbody>
</table><a name="7"></a>
<h3>Setting every property of a cell using specific colors</h3>
<p>This function modifies every property of a cell :<br /> * set the cell's background color to back.<br /> * set
the cell's foreground color to fore.<br /> * set the cell's ASCII code to c.<br /> </p>
<div class="code">
<p class="cpp"><span class="code-keyword">void</span> TCODConsole<span
class="code-symbol">::</span>putCharEx<span class="code-symbol">(</span><span
class="code-keyword">int</span> x<span class="code-symbol">,</span><span class="code-keyword"> int</span>
y<span class="code-symbol">,</span><span class="code-keyword"> int</span> c<span
class="code-symbol">,</span><span class="code-keyword"> const</span> TCODColor<span class="code-symbol">
&</span> fore<span class="code-symbol">,</span><span class="code-keyword"> const</span> TCODColor<span
class="code-symbol"> &</span> back<span class="code-symbol">)</span></p>
<p class="c"><span class="code-keyword">void</span> TCOD_console_put_char_ex<span
class="code-symbol">(</span><span class="code-tcod">TCOD_console_t</span> con<span
class="code-symbol">,</span><span class="code-keyword">int</span> x<span class="code-symbol">,</span><span
class="code-keyword"> int</span> y<span class="code-symbol">,</span><span class="code-keyword"> int</span>
c<span class="code-symbol">,</span><span class="code-tcod"> TCOD_color_t</span> fore<span
class="code-symbol">,</span><span class="code-tcod"> TCOD_color_t</span> back<span
class="code-symbol">)</span></p>
<p class="py">console_put_char_ex<span class="code-symbol">(</span> con<span class="code-symbol">,</span> x<span
class="code-symbol">,</span> y<span class="code-symbol">,</span> c<span class="code-symbol">,</span>
fore<span class="code-symbol">,</span> back<span class="code-symbol">)</span></p>
</div>
<table class="param">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr class="hilite">
<td>con</td>
<td>in the C and Python versions, the offscreen console handler or NULL for the root console<br /> </td>
</tr>
<tr>
<td>x,y</td>
<td>coordinates of the cell in the console.<br /> 0
<= x < console width<br /> 0
<= y < console height<br />
</td>
</tr>
<tr class="hilite">
<td>c</td>
<td>the new ASCII code for the cell. You can use ASCII constants<br /> </td>
</tr>
<tr>
<td>fore,back</td>
<td>new foreground and background colors for this cell<br /> </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="footer">
<div class="footertext">
<p>libtcod 1.6.4, © 2008, 2009, 2010, 2012, 2017 Jice, Mingos & rmtew<br>
This file has been generated by doctcod.</p>
<p>
<table width='100%'>
<tr>
<td width="33%"><a href="https://github.com/libtcod/libtcod">libtcod website</a></td>
<td width="33%"><a href="https://www.reddit.com/r/roguelikedev">libtcod on /r/roguelikedev</a></td>
<td width="33%">libtcod tutorials [ <a
href="http://www.roguebasin.com/index.php?title=Complete_Roguelike_Tutorial,_using_python%2Blibtcod">Python</a> | <a
href="http://www.roguebasin.com/index.php?title=Complete_roguelike_tutorial_using_C%2B%2B_and_libtcod_-_part_1:_setting_up">C++</a> ]
</td>
</tr>
</table>
</p>
</div>
</div>
</body>
<script>
initFilter();
SyntaxHighlighter.all();
</script>
</html>