5.3. Updating an image
Filling an image with a color
You can fill the whole image with a color with :
void TCODImage::clear(const TCODColor color)
void TCOD_image_clear(TCOD_image_t image, TCOD_color_t color)
image_clear(image,color)
void TCODImage::clear(TCODColor color)
Parameter | Description |
---|---|
image | In the C and python version, the image to fill. |
color | The color to use. |
Changing the color of a pixel
TCODColor TCODImage::putPixel(int x, int y, const TCODColor col)
void TCOD_image_put_pixel(TCOD_image_t image,int x, int y,TCOD_color_t col)
image_put_pixel(image,x, y,col)
TCODColor TCODImage::putPixel(int x, int y, TCODColor col)
Parameter | Description |
---|---|
image | In the C version, the image handler, obtained with the load function. |
x,y | The pixel coordinates inside the image. 0 <= x < width 0 <= y < height |
col | The new color of the pixel. |
Scaling an image
You can resize an image and scale its content. If neww < oldw or newh < oldh, supersampling is used to scale down the image. Else the image is scaled up using nearest neightbor.
void TCODImage::scale(int neww, int newh)
void TCOD_image_scale(TCOD_image_t image,int neww, int newh)
image_scale(image, neww,newh)
void TCODImage::scale(int neww, int newh)
Parameter | Description |
---|---|
image | In the C and python version, the image handler, obtained with the load function. |
neww,newh | The new size of the image. |
Flipping the image horizontally
void TCODImage::hflip()
void TCOD_image_hflip(TCOD_image_t image)
image_hflip(image)
void TCODImage::hflip()
Parameter | Description |
---|---|
image | In the C and python version, the image handler, obtained with the load function. |
Flipping the image vertically
void TCODImage::vflip()
void TCOD_image_vflip(TCOD_image_t image)
image_vflip(image)
void TCODImage::vflip()
Parameter | Description |
---|---|
image | In the C and python version, the image handler, obtained with the load function. |
Rotating the image clockwise
Rotate the image clockwise by increment of 90 degrees.
void TCODImage::rotate90(int numRotations=1)
void TCOD_image_rotate90(TCOD_image_t image, int numRotations)
image_rotate90(image, num=1)
void TCODImage::rotate90(int numRotations)
Parameter | Description |
---|---|
image | In the C and python version, the image handler, obtained with the load function. |
numRotations | Number of 90 degrees rotations. Should be between 1 and 3. |
Inverting the colors of the image
void TCODImage::invert()
void TCOD_image_invert(TCOD_image_t image)
image_invert(image)
void TCODImage::invert()
Parameter | Description |
---|---|
image | In the C and python version, the image handler, obtained with the load function. |