There are functions for interfacing with bmovl, rendering text, controlling timers and a bunch of other stuff.
#include <sys/poll.h>
#include <fcntl.h>
#include "bitmap.h"
Go to the source code of this file.
Compounds | |
class | Readfd |
Class for doing secure, non-blocking, line-buffered reads from any file descriptor. More... | |
Interface to the bmovl protocol | |
void | blit (const Bitmap &bitmap, int xpos, int ypos, int alpha=0, int clear=0) |
Send a bitmap to the screen. | |
void | set_alpha (int width, int height, int xpos, int ypos, int alpha) |
Set the alpha value for a rectangle to a value between -255 and 255. | |
void | clear (int width, int height, int xpos, int ypos) |
Clear an area. | |
void | clear () |
Clear the whole screen. | |
Bitmap generating functions | |
void | text (RGBA &bitmap, int width, char *str, int size=0, char *align="left") |
The basic routine for rendering text. | |
void | text_trimmed (RGBA &bitmap, int width, int height, char *str, int size=0, char *align="left") |
Works like text() but guarantees that the text will be no bigger than width x height , and that the width and height will be multiples of 2. | |
void | text_constsize (RGBA &bitmap, char *str, int size=0, char *align="left") |
Works like text() but puts the text into a pre-allocated bitmap. | |
Bitmap * | load_image (const char *filename) |
Loads an image file from any format supported by SDL_image or Imlib2 (jpg, png, gif, etc.) and returns the type of Bitmap that best fits its color space. | |
Bitmap * | load_image_from_mem (const char *ptr, size_t len) |
Loads an image from a pointer to memory instead of a filename. | |
Timing related functions | |
void | settimer_ms (int milliseconds) |
Starts a one-shot itimer. | |
int | gettimer_ms () |
Gets the value of an itimer. | |
void | msleep (int msec) |
Sleeps for the requested number of milliseconds. | |
int | runtime () |
Returns the number of milliseconds that have passed since it was first called (which means that the first call will always return 0). | |
Misc functions | |
int | tcp_connect (const char *host, short port) |
Establishes a tcp socket connection to the given host/port. | |
void | msg (int level, char *format,...) __attribute__((format(printf |
Prints a message to stderr, but only if level is equal to or less than the global variable verbosity . | |
int | scalefont (int percent) |
Returns a size in pixels representing approximately how tall the font will be if it takes up percent percent of the screen. | |
int | center (int s, int S) |
Simple algorithm for centering something with the size s inside a larger object with the size S . | |
int | inrange (int num, int lo, int hi) |
Bounds-checks num against the lo and hi boundaries. | |
Defines | |
#define | __attribute__(x) |
|
Send a bitmap to the screen. It's ok to supply a bitmap that's partially or completely out out of bounds, it'll just be cropped before being shown. |
|
Simple algorithm for centering something with the size Use it for the sake of clarity. |
|
Gets the value of an itimer. See gettitimer(2) for more info. |
|
Loads an image file from any format supported by SDL_image or Imlib2 (jpg, png, gif, etc.) and returns the type of Bitmap that best fits its color space. Returns NULL and prints a warning if loading fails |
|
Prints a message to stderr, but only if 1=normal, 2=verbose, 3=debug. |
|
Sleeps for the requested number of milliseconds.
Returns immediately if |
|
Returns the number of milliseconds that have passed since it was first called (which means that the first call will always return 0). On broken hardware this timer may go backwards some times. |
|
Returns a size in pixels representing approximately how tall the font will be if it takes up This of course depends on the font, so it should only be used as an approximate value. |
|
Set the alpha value for a rectangle to a value between -255 and 255. 255 makes everything opaque. -255 makes everything transparent. The coordinates don't have to fit in screen boundaries In bmovl there are two alpha channels: one for the image that can only be set with the alpha pixels in the bitmap supplied to blit() and another one that can be set with the alpha parameter to blit() or set_alpha(), mostly used to set the alpha of a large chunk. The two alpha channels will be added together and then truncated so the final result is between 0 and 255. |
|
Starts a one-shot itimer. See setitimer(2) for more info. |
|
The basic routine for rendering text.
The width parameter specifies in pixels where word wrapping should occur, but the resulting bitmap may be bigger if word wrapping is not possible. A positive |