ASCII-GFX  2.0
Functions
scrollarea.h File Reference
#include "gfx.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void set_drawing_window (WINDOW *w)
 set the drawing window More...
 
void set_area_size (int sx, int sy)
 create a scrollable canvas area More...
 
bool has_area ()
 is a scrollable canvas area available? More...
 
int get_area_width ()
 get the width of the scrollable area More...
 
int get_area_height ()
 get the height of the scrollable area More...
 
void set_window_size (int sx, int sy)
 set the size of the displayed window More...
 
bool has_window ()
 is a displayed window available? More...
 
int get_window_width ()
 get the width of the displayed window More...
 
int get_window_height ()
 get the height of the displayed window More...
 
void set_window_offset (int ox, int oy)
 set the offset of the displayed window More...
 
void clear_area (int ch=' ')
 clear the scrollable area More...
 
void set_area_border (int ch=ACS_CKBOARD)
 set the border of the scrollable area More...
 
void set_window_border (int ch=ACS_CKBOARD)
 set the border of the displayed window More...
 
int get_cell (int x, int y)
 get the cell character at position (x, y) of the canvas area More...
 
int get_ascii (int x, int y)
 get the ascii character at cell position (x, y) More...
 
void set_cell (int x, int y, int ch)
 set the cell at position (x, y) to character ch of the canvas area More...
 
void use_cell_color (int index=1)
 use indexed color pair for foreground/background colors of cells More...
 
void set_cell_offset (int x=0, int y=0)
 set the cell coordinate offset More...
 
void set_cell_mode (bool retain=false)
 set the cell modification mode More...
 
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) More...
 
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) More...
 
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) More...
 
int render_text_area (int x, int y, const char *text)
 render a text area at top-left position (x, y) More...
 
int render_text_format (int x, int y, const char *format,...)
 render a formatted text at position (x, y) More...
 
void render_grid_char (int x, int y, int ch)
 render a grid font character at top-left position (x, y) More...
 
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) More...
 
void render_line (int x1, int y1, int x2, int y2, int ch=-1)
 render a line from position (x1, y1) to (x2, y2) More...
 
void render_frame (int x1, int y1, int x2, int y2, int ch=-1)
 render a frame from position (x1, y1) to (x2, y2) More...
 
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 More...
 
void render_ellipse (int xc, int yc, int ax, int ay, int ch=-1, double aspect=2)
 
void flood_fill (int x, int y, int ch=-1)
 flood-fill a cell area starting at position (x, y) More...
 
void inverse_flood_fill (int x, int y, int ch=-1)
 flood-fill everything but a cell area starting at position (x, y) More...
 
void scroll_area_up ()
 scroll the content of the canvas area up More...
 
void scroll_area_down (int num)
 scroll the content of the canvas area down More...
 
void scroll_area_left (int num)
 scroll the content of the canvas area left More...
 
void scroll_area_right (int num)
 scroll the content of the canvas area right More...
 
int get_sprite_num ()
 
void enable_sprite (int num, int sx, int sy, bool window=false, bool own=false)
 enable a sprite overlay More...
 
bool is_sprite_enabled (int num)
 is a sprite overlay enabled? More...
 
int get_sprite_width (int num)
 get the width of a sprite More...
 
int get_sprite_height (int num)
 get the height of a sprite More...
 
void clear_sprite (int num, int ch=-1)
 clear a sprite More...
 
void set_sprite_data (int num, int sx, int sy, int *data)
 set the sprite data More...
 
int * get_sprite_data (int num)
 get the sprite data More...
 
void set_sprite_text (int num, const char *text, int ch=-1, bool interprete=false)
 set the sprite data by text string More...
 
void fill_sprite_area (int num, int x, int y, int sx, int sy, int ch=-1)
 fill a sprite cell area More...
 
void set_sprite_area (int num, int x, int y, int sx, int sy, const int *data)
 set a sprite cell area More...
 
int print_sprite_text (int num, int x, int y, const char *text)
 print a sprite text area More...
 
void print_sprite_grid_char (int num, int x, int y, int ch)
 print a sprite grid font character More...
 
void print_sprite_grid_text (int num, int x, int y, const char *text)
 print a sprite text string with grid font characters More...
 
void mirror_sprite_horizontal (int num, bool flip=true)
 mirror the sprite horizontally More...
 
void mirror_sprite_vertical (int num, bool flip=true)
 mirror the sprite vertically More...
 
void scroll_sprite_up (int num)
 scroll the sprite up More...
 
void scroll_sprite_down (int num)
 scroll the sprite down More...
 
void scroll_sprite_left (int num)
 scroll the sprite left More...
 
void scroll_sprite_right (int num)
 scroll the sprite right More...
 
void set_sprite_position (int num, int x, int y)
 set the sprite position More...
 
void center_sprite_position (int num, int x, int y)
 center the sprite position More...
 
void get_sprite_position (int num, int *x, int *y)
 get the sprite position More...
 
void hide_sprite (int num)
 hide a sprite More...
 
void show_sprite (int num)
 show a sprite More...
 
void background_sprite (int num, bool background=true)
 make background sprite More...
 
void parallax_sprite (int num, float dx, float dy)
 make parallax sprite More...
 
bool detect_area_collision (int num, int ch=-1, const char *empty=NULL)
 detect a sprite collision with a non-empty canvas area More...
 
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 More...
 
bool detect_sprite_collision (int num, int spr)
 detect a sprite collision with a non-transparent area of another sprite More...
 
bool detect_sprite_touch (int num, int dx, int dy, int spr)
 detect a sprite touch with a non-transparent area of another sprite More...
 
void bake_sprite (int num)
 bake the sprite into the canvas area More...
 
void disable_sprite (int num)
 disable a sprite More...
 
void disable_sprites ()
 disable all sprites More...
 
void redraw_window (int x, int y)
 redraw the displayed window at top-left position (x, y) More...
 
void position_window (int x, int y)
 position the displayed window at center position (x, y) More...
 
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) More...
 
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) More...
 
void get_window (int *x, int *y)
 get the top-left position (x, y) of the scrolled window More...
 
void release_area ()
 release allocated memory More...
 

Function Documentation

◆ background_sprite()

void background_sprite ( int  num,
bool  background = true 
)

make background sprite

  • "num" is the number of the sprite
  • a background sprite only shows where the canvas area is empty
  • an empty area is filled with spaces

◆ bake_sprite()

void bake_sprite ( int  num)

bake the sprite into the canvas area

  • "num" is the number of the sprite

◆ center_sprite_position()

void center_sprite_position ( int  num,
int  x,
int  y 
)

center the sprite position

  • "num" is the number of the sprite
  • "x" and "y" is the center position of the sprite

◆ 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)

  • "deltax" and "deltay" is the position delta that triggers scrolling
  • "stop" determines if scrolling should stop at the edges of the scrollable area

◆ clear_area()

void clear_area ( int  ch = ' ')

clear the scrollable area

  • "ch" is the character used to clear the area

◆ clear_sprite()

void clear_sprite ( int  num,
int  ch = -1 
)

clear a sprite

  • "num" is the number of the sprite
  • "ch" is the character to be set
  • by default the sprite is made fully transparent

◆ 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

  • "num" is the number of the sprite
  • "ch" is the character that represents empty areas
  • "empty" contains characters that also represent empty areas
  • empty areas are represented by space by default

◆ 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

  • "num" is the number of the sprite
  • (dx, dy) is the direction vector of the touch detection
  • "ch" is the character that represents empty areas
  • "empty" contains characters that also represent empty areas
  • non-empty areas are represented by anything but space by default

◆ detect_sprite_collision()

bool detect_sprite_collision ( int  num,
int  spr 
)

detect a sprite collision with a non-transparent area of another sprite

  • "num" is the number of the sprite
  • "spr" is the number of the other sprite
  • non-transparent areas are represented by positive cell values

◆ 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

  • "num" is the number of the sprite
  • "spr" is the number of the other sprite
  • non-transparent areas are represented by positive cell values

◆ disable_sprite()

void disable_sprite ( int  num)

disable a sprite

  • "num" is the number of the sprite

◆ disable_sprites()

void disable_sprites ( )

disable all sprites

◆ enable_sprite()

void enable_sprite ( int  num,
int  sx,
int  sy,
bool  window = false,
bool  own = false 
)

enable a sprite overlay

  • "num" is the number of the sprite
  • "sx" and "sy" is the cell area size of the sprite
  • "window" determines if the sprite position is area or window relative
  • "own" determines that the data is provided by set_sprite_data and is owned by the user
  • by default the sprite is fully transparent

◆ 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)

  • "ch" is the character used to fill the area
    • by default ACS_CKBOARD is used as character

◆ 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

  • "num" is the number of the sprite
  • "x" and "y" is the top-left position (x, y) of the sub-area to be cleared
  • "sx" and "sy" is the size of the sub-area to be cleared
  • "ch" is the character to be copied into the sub-area
    • by default ACS_CKBOARD is used as character

◆ flood_fill()

void flood_fill ( int  x,
int  y,
int  ch = -1 
)

flood-fill a cell area starting at position (x, y)

  • "ch" is the character used to fill the area
    • by default ACS_CKBOARD is used as character

◆ get_area_height()

int get_area_height ( )

get the height of the scrollable area

◆ get_area_width()

int get_area_width ( )

get the width of the scrollable area

◆ get_ascii()

int get_ascii ( int  x,
int  y 
)

get the ascii character at cell position (x, y)

  • ncurses attributes like color indices are excluded

◆ get_cell()

int get_cell ( int  x,
int  y 
)

get the cell character at position (x, y) of the canvas area

◆ 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)

  • "ch" is the character that represents transparent areas
  • returns a newly allocated array of respective size

◆ get_sprite_data()

int* get_sprite_data ( int  num)

get the sprite data

  • transparent areas are represented by negative cell values

◆ get_sprite_height()

int get_sprite_height ( int  num)

get the height of a sprite

  • "num" is the number of the sprite

◆ get_sprite_num()

int get_sprite_num ( )

◆ get_sprite_position()

void get_sprite_position ( int  num,
int *  x,
int *  y 
)

get the sprite position

  • "num" is the number of the sprite
  • "x" and "y" will be the top-left position (x, y) of the sprite

◆ get_sprite_width()

int get_sprite_width ( int  num)

get the width of a sprite

  • "num" is the number of the sprite

◆ get_window()

void get_window ( int *  x,
int *  y 
)

get the top-left position (x, y) of the scrolled window

◆ get_window_height()

int get_window_height ( )

get the height of the displayed window

◆ get_window_width()

int get_window_width ( )

get the width of the displayed window

◆ has_area()

bool has_area ( )

is a scrollable canvas area available?

◆ has_window()

bool has_window ( )

is a displayed window available?

◆ hide_sprite()

void hide_sprite ( int  num)

hide a sprite

  • "num" is the number of the sprite

◆ 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)

  • "ch" is the character used to fill the area
    • by default ACS_CKBOARD is used as character

◆ is_sprite_enabled()

bool is_sprite_enabled ( int  num)

is a sprite overlay enabled?

  • "num" is the number of the sprite

◆ mirror_sprite_horizontal()

void mirror_sprite_horizontal ( int  num,
bool  flip = true 
)

mirror the sprite horizontally

  • "num" is the number of the sprite
  • "flip" determines whether a slash is replaced with a backslash or vice versa

◆ mirror_sprite_vertical()

void mirror_sprite_vertical ( int  num,
bool  flip = true 
)

mirror the sprite vertically

  • "num" is the number of the sprite
  • "flip" determines whether
    • a slash is replaced with a backslash or vice versa
    • an underscore is replaced with an overscore or vice versa

◆ parallax_sprite()

void parallax_sprite ( int  num,
float  dx,
float  dy 
)

make parallax sprite

  • "num" is the number of the sprite
  • a parallax sprite scrolls relative to the viewing coordinates
  • "dx" and "dy" define the amount of parallax scrolling

◆ position_window()

void position_window ( int  x,
int  y 
)

position the displayed window at center position (x, y)

  • it is assumed that the displayed window area has been cleared once
  • subsequent calls will only update modifications to the canvas area

◆ print_sprite_grid_char()

void print_sprite_grid_char ( int  num,
int  x,
int  y,
int  ch 
)

print a sprite grid font character

  • "num" is the number of the sprite
  • "x" and "y" is the top-left position (x, y) of the character to be printed
  • "ch" is the character to be printed

◆ 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

  • "num" is the number of the sprite
  • "x" and "y" is the top-left position (x, y) of the text to be printed
  • "text" is the string to be printed
  • the grid area is made up from consecutive text lines separated by \n

◆ print_sprite_text()

int print_sprite_text ( int  num,
int  x,
int  y,
const char *  text 
)

print a sprite text area

  • "num" is the number of the sprite
  • "x" and "y" is the top-left position (x, y) of the text to be printed
  • "text" is the string to be printed
  • the text area is made up from consecutive text lines separated by \n
  • return value is the number of printed text lines

◆ redraw_window()

void redraw_window ( int  x,
int  y 
)

redraw the displayed window at top-left position (x, y)

  • it is assumed that the displayed window area has been cleared once
  • subsequent calls will only update modifications to the canvas area

◆ release_area()

void release_area ( )

release allocated memory

◆ 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)

  • the data is made up from consecutive lines of characters

◆ 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

  • "ch" is the character used to render the circle
    • by default graphical characters are used

◆ render_ellipse()

void render_ellipse ( int  xc,
int  yc,
int  ax,
int  ay,
int  ch = -1,
double  aspect = 2 
)
  • "ch" is the character used to render the ellipse
    • by default graphical characters are used

◆ 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)

  • "ch" is the character used to render the frame
    • by default graphical characters are used

◆ render_grid_char()

void render_grid_char ( int  x,
int  y,
int  ch 
)

render a grid font character at top-left position (x, y)

◆ 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)

  • the grid area is made up from consecutive text lines separated by \n

◆ 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)

  • "ch" is the character used to render the line
    • by default graphical characters are used

◆ render_text_area()

int render_text_area ( int  x,
int  y,
const char *  text 
)

render a text area at top-left position (x, y)

  • the text area is made up from consecutive text lines separated by \n
  • return value is the number of rendered text lines

◆ render_text_format()

int render_text_format ( int  x,
int  y,
const char *  format,
  ... 
)

render a formatted text at position (x, y)

  • the text area is made up from consecutive text lines separated by \n
  • the text may contain conversion symbols starting with ''
  • return value is the number of rendered text lines

◆ scroll_area_down()

void scroll_area_down ( int  num)

scroll the content of the canvas area down

◆ scroll_area_left()

void scroll_area_left ( int  num)

scroll the content of the canvas area left

◆ scroll_area_right()

void scroll_area_right ( int  num)

scroll the content of the canvas area right

◆ scroll_area_up()

void scroll_area_up ( )

scroll the content of the canvas area up

◆ scroll_sprite_down()

void scroll_sprite_down ( int  num)

scroll the sprite down

  • "num" is the number of the sprite

◆ scroll_sprite_left()

void scroll_sprite_left ( int  num)

scroll the sprite left

  • "num" is the number of the sprite

◆ scroll_sprite_right()

void scroll_sprite_right ( int  num)

scroll the sprite right

  • "num" is the number of the sprite

◆ scroll_sprite_up()

void scroll_sprite_up ( int  num)

scroll the sprite up

  • "num" is the number of the sprite

◆ 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)

  • "deltax" and "deltay" is the position delta that triggers scrolling
  • "stop" determines if scrolling should stop at the edges of the scrollable area

◆ set_area_border()

void set_area_border ( int  ch = ACS_CKBOARD)

set the border of the scrollable area

  • "ch" is the character used for the area border

◆ set_area_size()

void set_area_size ( int  sx,
int  sy 
)

create a scrollable canvas area

  • with sx columns and sy rows
  • the canvas area may contain a single ASCII character per cell
  • by default the canvas area is empty (filled with spaces)
  • after canvas area creation we need to
    • define the screen window size via set_window_size
    • define the contents of the canvas area via set_cell, flood_fill etc.
    • and finally render the canvas via redraw_window or center_window

◆ 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

◆ set_cell_mode()

void set_cell_mode ( bool  retain = false)

set the cell modification mode

  • in retain mode only spaces will be overwritten via set_cell

◆ set_cell_offset()

void set_cell_offset ( int  x = 0,
int  y = 0 
)

set the cell coordinate offset

  • the coordinate offset is applied both to get_cell and set_cell
  • the offset is added implicitly to the supplied cell coordinates

◆ set_drawing_window()

void set_drawing_window ( WINDOW *  w)

set the drawing window

  • stdscr is used by default

◆ 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

  • "num" is the number of the sprite
  • "x" and "y" is the top-left position (x, y) of the sub-area to be set
  • "sx" and "sy" is the size of the sub-area to be set
  • "data" is the data to be copied into the sub-area
  • negative data values are not copied having a transparency effect

◆ set_sprite_data()

void set_sprite_data ( int  num,
int  sx,
int  sy,
int *  data 
)

set the sprite data

  • transparent areas are represented by negative cell values

◆ set_sprite_position()

void set_sprite_position ( int  num,
int  x,
int  y 
)

set the sprite position

  • "num" is the number of the sprite
  • "x" and "y" is the top-left position (x, y) of the sprite

◆ 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

  • "ch" is the character that represents transparent areas
  • when "interprete" is enabled treat special characters as follows:
    • ^ as overscore
    • # as checker board
    • B as bold attribute
    • digits as color attributes
    • 0 to clear attributes

◆ set_window_border()

void set_window_border ( int  ch = ACS_CKBOARD)

set the border of the displayed window

  • "ch" is the character used for the window border

◆ set_window_offset()

void set_window_offset ( int  ox,
int  oy 
)

set the offset of the displayed window

◆ set_window_size()

void set_window_size ( int  sx,
int  sy 
)

set the size of the displayed window

◆ show_sprite()

void show_sprite ( int  num)

show a sprite

  • "num" is the number of the sprite

◆ use_cell_color()

void use_cell_color ( int  index = 1)

use indexed color pair for foreground/background colors of cells

  • colors need to be initialized beforehand via init_color()
  • 1 = white/black
  • 2 = red/black
  • 3 = green/black
  • 4 = blue/black
  • 5 = yellow/black
  • 6 = cyan/black
  • 7 = magenta/black
  • 8 = black/white
  • 9 = black/black
  • 0 = disabled