ASCII-GFX  2.0
scrollarea.h
Go to the documentation of this file.
1 // NCurses side-scrolling area
2 // (c) 2020 by Stefan Roettger
3 
4 #pragma once
5 
6 #include "gfx.h"
7 
10 void set_drawing_window(WINDOW *w);
11 
20 void set_area_size(int sx, int sy);
21 
23 bool has_area();
24 
26 int get_area_width();
27 
29 int get_area_height();
30 
32 void set_window_size(int sx, int sy);
33 
35 bool has_window();
36 
38 int get_window_width();
39 
41 int get_window_height();
42 
44 void set_window_offset(int ox, int oy);
45 
48 void clear_area(int ch = ' ');
49 
52 void set_area_border(int ch = ACS_CKBOARD);
53 
56 void set_window_border(int ch = ACS_CKBOARD);
57 
59 int get_cell(int x, int y);
60 
63 int get_ascii(int x, int y);
64 
66 void set_cell(int x, int y, int ch);
67 
80 void use_cell_color(int index = 1);
81 
85 void set_cell_offset(int x = 0, int y = 0);
86 
89 void set_cell_mode(bool retain = false);
90 
94 int *get_cell_area(int x, int y,
95  int sx, int sy,
96  int ch = -1);
97 
101 void fill_cell_area(int x, int y,
102  int sx, int sy,
103  int ch = -1);
104 
107 void render_cell_area(int x, int y,
108  int sx, int sy,
109  const int *data);
110 
114 int render_text_area(int x, int y,
115  const char *text);
116 
121 int render_text_format(int x, int y,
122  const char *format, ...);
123 
125 void render_grid_char(int x, int y, int ch);
126 
129 void render_grid_text(int x, int y,
130  const char *text);
131 
135 void render_line(int x1, int y1, int x2, int y2,
136  int ch = -1);
137 
141 void render_frame(int x1, int y1, int x2, int y2,
142  int ch = -1);
143 
147 void render_circle(int xc, int yc, int r,
148  int ch = -1, double aspect = 2);
149 
150 // render a ellipse at center position (xc, yc) with principle axis ax and ay
153 void render_ellipse(int xc, int yc, int ax, int ay,
154  int ch = -1, double aspect = 2);
155 
159 void flood_fill(int x, int y, int ch = -1);
160 
164 void inverse_flood_fill(int x, int y, int ch = -1);
165 
167 void scroll_area_up();
168 
170 void scroll_area_down(int num);
171 
173 void scroll_area_left(int num);
174 
176 void scroll_area_right(int num);
177 
178 // get the number of available sprite overlays
179 int get_sprite_num();
180 
187 void enable_sprite(int num,
188  int sx, int sy,
189  bool window = false,
190  bool own = false);
191 
194 bool is_sprite_enabled(int num);
195 
198 int get_sprite_width(int num);
199 
202 int get_sprite_height(int num);
203 
208 void clear_sprite(int num, int ch = -1);
209 
212 void set_sprite_data(int num, int sx, int sy, int *data);
213 
216 int *get_sprite_data(int num);
217 
226 void set_sprite_text(int num, const char *text,
227  int ch = -1, bool interprete = false);
228 
235 void fill_sprite_area(int num, int x, int y, int sx, int sy, int ch = -1);
236 
243 void set_sprite_area(int num, int x, int y, int sx, int sy, const int *data);
244 
251 int print_sprite_text(int num,
252  int x, int y,
253  const char *text);
254 
259 void print_sprite_grid_char(int num,
260  int x, int y,
261  int ch);
262 
268 void print_sprite_grid_text(int num,
269  int x, int y,
270  const char *text);
271 
275 void mirror_sprite_horizontal(int num, bool flip = true);
276 
282 void mirror_sprite_vertical(int num, bool flip = true);
283 
286 void scroll_sprite_up(int num);
287 
290 void scroll_sprite_down(int num);
291 
294 void scroll_sprite_left(int num);
295 
298 void scroll_sprite_right(int num);
299 
303 void set_sprite_position(int num, int x, int y);
304 
308 void center_sprite_position(int num, int x, int y);
309 
313 void get_sprite_position(int num, int *x, int *y);
314 
317 void hide_sprite(int num);
318 
321 void show_sprite(int num);
322 
327 void background_sprite(int num, bool background = true);
328 
333 void parallax_sprite(int num, float dx, float dy);
334 
340 bool detect_area_collision(int num, int ch = -1, const char *empty = NULL);
341 
348 bool detect_area_touch(int num, int dx, int dy, int ch = -1, const char *empty = NULL);
349 
354 bool detect_sprite_collision(int num, int spr);
355 
360 bool detect_sprite_touch(int num, int dx, int dy, int spr);
361 
364 void bake_sprite(int num);
365 
368 void disable_sprite(int num);
369 
371 void disable_sprites();
372 
376 void redraw_window(int x, int y);
377 
381 void position_window(int x, int y);
382 
386 void scroll_window(int x, int y, int deltax = 0, int deltay = 0, bool stop = true);
387 
391 void center_window(int x, int y, int deltax = 0, int deltay = 0, bool stop = true);
392 
394 void get_window(int *x, int *y);
395 
397 void release_area();
scroll_window
void scroll_window(int x, int y, int deltax=0, int deltay=0, bool stop=true)
scroll the displayed window to top-left position (x, y)
Definition: scrollarea.cpp:1325
scroll_area_down
void scroll_area_down(int num)
scroll the content of the canvas area down
Definition: scrollarea.cpp:619
get_sprite_position
void get_sprite_position(int num, int *x, int *y)
get the sprite position
Definition: scrollarea.cpp:1023
set_cell_mode
void set_cell_mode(bool retain=false)
set the cell modification mode
Definition: scrollarea.cpp:231
render_text_format
int render_text_format(int x, int y, const char *format,...)
render a formatted text at position (x, y)
Definition: scrollarea.cpp:321
set_cell
void set_cell(int x, int y, int ch)
set the cell at position (x, y) to character ch of the canvas area
Definition: scrollarea.cpp:192
scroll_area_right
void scroll_area_right(int num)
scroll the content of the canvas area right
Definition: scrollarea.cpp:641
set_drawing_window
void set_drawing_window(WINDOW *w)
set the drawing window
Definition: scrollarea.cpp:42
mirror_sprite_vertical
void mirror_sprite_vertical(int num, bool flip=true)
mirror the sprite vertically
Definition: scrollarea.cpp:907
set_sprite_position
void set_sprite_position(int num, int x, int y)
set the sprite position
Definition: scrollarea.cpp:1002
get_area_height
int get_area_height()
get the height of the scrollable area
Definition: scrollarea.cpp:84
print_sprite_text
int print_sprite_text(int num, int x, int y, const char *text)
print a sprite text area
Definition: scrollarea.cpp:804
set_sprite_area
void set_sprite_area(int num, int x, int y, int sx, int sy, const int *data)
set a sprite cell area
Definition: scrollarea.cpp:786
clear_area
void clear_area(int ch=' ')
clear the scrollable area
Definition: scrollarea.cpp:134
render_cell_area
void render_cell_area(int x, int y, int sx, int sy, const int *data)
render a cell area at top-left position (x, y) with size (sx, sy)
Definition: scrollarea.cpp:276
scroll_sprite_right
void scroll_sprite_right(int num)
scroll the sprite right
Definition: scrollarea.cpp:986
background_sprite
void background_sprite(int num, bool background=true)
make background sprite
Definition: scrollarea.cpp:1054
set_area_size
void set_area_size(int sx, int sy)
create a scrollable canvas area
Definition: scrollarea.cpp:52
scroll_sprite_up
void scroll_sprite_up(int num)
scroll the sprite up
Definition: scrollarea.cpp:938
get_window
void get_window(int *x, int *y)
get the top-left position (x, y) of the scrolled window
Definition: scrollarea.cpp:1358
scroll_area_left
void scroll_area_left(int num)
scroll the content of the canvas area left
Definition: scrollarea.cpp:630
detect_area_collision
bool detect_area_collision(int num, int ch=-1, const char *empty=NULL)
detect a sprite collision with a non-empty canvas area
Definition: scrollarea.cpp:1076
print_sprite_grid_char
void print_sprite_grid_char(int num, int x, int y, int ch)
print a sprite grid font character
Definition: scrollarea.cpp:840
get_cell
int get_cell(int x, int y)
get the cell character at position (x, y) of the canvas area
Definition: scrollarea.cpp:167
disable_sprites
void disable_sprites()
disable all sprites
Definition: scrollarea.cpp:1216
release_area
void release_area()
release allocated memory
Definition: scrollarea.cpp:1365
detect_area_touch
bool detect_area_touch(int num, int dx, int dy, int ch=-1, const char *empty=NULL)
detect a sprite touch with a non-empty canvas area
Definition: scrollarea.cpp:1105
center_sprite_position
void center_sprite_position(int num, int x, int y)
center the sprite position
Definition: scrollarea.cpp:1013
parallax_sprite
void parallax_sprite(int num, float dx, float dy)
make parallax sprite
Definition: scrollarea.cpp:1064
redraw_window
void redraw_window(int x, int y)
redraw the displayed window at top-left position (x, y)
Definition: scrollarea.cpp:1226
show_sprite
void show_sprite(int num)
show a sprite
Definition: scrollarea.cpp:1044
gfx.h
set_area_border
void set_area_border(int ch=ACS_CKBOARD)
set the border of the scrollable area
Definition: scrollarea.cpp:145
flood_fill
void flood_fill(int x, int y, int ch=-1)
flood-fill a cell area starting at position (x, y)
Definition: scrollarea.cpp:572
render_text_area
int render_text_area(int x, int y, const char *text)
render a text area at top-left position (x, y)
Definition: scrollarea.cpp:293
set_sprite_text
void set_sprite_text(int num, const char *text, int ch=-1, bool interprete=false)
set the sprite data by text string
Definition: scrollarea.cpp:753
has_area
bool has_area()
is a scrollable canvas area available?
Definition: scrollarea.cpp:72
get_area_width
int get_area_width()
get the width of the scrollable area
Definition: scrollarea.cpp:78
render_ellipse
void render_ellipse(int xc, int yc, int ax, int ay, int ch=-1, double aspect=2)
Definition: scrollarea.cpp:514
get_cell_area
int * get_cell_area(int x, int y, int sx, int sy, int ch=-1)
get the cell area at top-left position (x, y) with size (sx, sy)
Definition: scrollarea.cpp:237
set_sprite_data
void set_sprite_data(int num, int sx, int sy, int *data)
set the sprite data
Definition: scrollarea.cpp:722
center_window
void center_window(int x, int y, int deltax=0, int deltay=0, bool stop=true)
scroll the displayed window to center position (x, y)
Definition: scrollarea.cpp:1352
bake_sprite
void bake_sprite(int num)
bake the sprite into the canvas area
Definition: scrollarea.cpp:1194
render_grid_text
void render_grid_text(int x, int y, const char *text)
render a text string with grid font characters at top-left position (x, y)
Definition: scrollarea.cpp:348
detect_sprite_collision
bool detect_sprite_collision(int num, int spr)
detect a sprite collision with a non-transparent area of another sprite
Definition: scrollarea.cpp:1128
render_grid_char
void render_grid_char(int x, int y, int ch)
render a grid font character at top-left position (x, y)
Definition: scrollarea.cpp:338
use_cell_color
void use_cell_color(int index=1)
use indexed color pair for foreground/background colors of cells
Definition: scrollarea.cpp:218
inverse_flood_fill
void inverse_flood_fill(int x, int y, int ch=-1)
flood-fill everything but a cell area starting at position (x, y)
Definition: scrollarea.cpp:589
get_sprite_num
int get_sprite_num()
Definition: scrollarea.cpp:652
enable_sprite
void enable_sprite(int num, int sx, int sy, bool window=false, bool own=false)
enable a sprite overlay
Definition: scrollarea.cpp:658
scroll_area_up
void scroll_area_up()
scroll the content of the canvas area up
Definition: scrollarea.cpp:608
get_sprite_data
int * get_sprite_data(int num)
get the sprite data
Definition: scrollarea.cpp:745
fill_cell_area
void fill_cell_area(int x, int y, int sx, int sy, int ch=-1)
fill a cell area at top-left position (x, y) with size (sx, sy)
Definition: scrollarea.cpp:259
set_window_offset
void set_window_offset(int ox, int oy)
set the offset of the displayed window
Definition: scrollarea.cpp:123
position_window
void position_window(int x, int y)
position the displayed window at center position (x, y)
Definition: scrollarea.cpp:1319
get_sprite_height
int get_sprite_height(int num)
get the height of a sprite
Definition: scrollarea.cpp:701
get_ascii
int get_ascii(int x, int y)
get the ascii character at cell position (x, y)
Definition: scrollarea.cpp:186
window
static int * window
Definition: scrollarea.cpp:16
get_sprite_width
int get_sprite_width(int num)
get the width of a sprite
Definition: scrollarea.cpp:693
scroll_sprite_down
void scroll_sprite_down(int num)
scroll the sprite down
Definition: scrollarea.cpp:954
clear_sprite
void clear_sprite(int num, int ch=-1)
clear a sprite
Definition: scrollarea.cpp:709
hide_sprite
void hide_sprite(int num)
hide a sprite
Definition: scrollarea.cpp:1034
set_window_size
void set_window_size(int sx, int sy)
set the size of the displayed window
Definition: scrollarea.cpp:90
scroll_sprite_left
void scroll_sprite_left(int num)
scroll the sprite left
Definition: scrollarea.cpp:970
disable_sprite
void disable_sprite(int num)
disable a sprite
Definition: scrollarea.cpp:1204
set_window_border
void set_window_border(int ch=ACS_CKBOARD)
set the border of the displayed window
Definition: scrollarea.cpp:161
is_sprite_enabled
bool is_sprite_enabled(int num)
is a sprite overlay enabled?
Definition: scrollarea.cpp:685
render_line
void render_line(int x1, int y1, int x2, int y2, int ch=-1)
render a line from position (x1, y1) to (x2, y2)
Definition: scrollarea.cpp:375
render_circle
void render_circle(int xc, int yc, int r, int ch=-1, double aspect=2)
render a circle at center position (xc, yc) with radius r
Definition: scrollarea.cpp:488
set_cell_offset
void set_cell_offset(int x=0, int y=0)
set the cell coordinate offset
Definition: scrollarea.cpp:224
print_sprite_grid_text
void print_sprite_grid_text(int num, int x, int y, const char *text)
print a sprite text string with grid font characters
Definition: scrollarea.cpp:852
get_window_width
int get_window_width()
get the width of the displayed window
Definition: scrollarea.cpp:111
fill_sprite_area
void fill_sprite_area(int num, int x, int y, int sx, int sy, int ch=-1)
fill a sprite cell area
Definition: scrollarea.cpp:772
get_window_height
int get_window_height()
get the height of the displayed window
Definition: scrollarea.cpp:117
mirror_sprite_horizontal
void mirror_sprite_horizontal(int num, bool flip=true)
mirror the sprite horizontally
Definition: scrollarea.cpp:880
render_frame
void render_frame(int x1, int y1, int x2, int y2, int ch=-1)
render a frame from position (x1, y1) to (x2, y2)
Definition: scrollarea.cpp:463
detect_sprite_touch
bool detect_sprite_touch(int num, int dx, int dy, int spr)
detect a sprite touch with a non-transparent area of another sprite
Definition: scrollarea.cpp:1170
has_window
bool has_window()
is a displayed window available?
Definition: scrollarea.cpp:105