tcod-haskell-0.1.0.0: Bindings to libtcod roguelike engine

Safe HaskellNone
LanguageHaskell2010

Game.TCOD.Image

Synopsis

Documentation

newtype TCODImage Source #

TCOD image

Constructors

TCODImage 

Fields

Instances

Eq TCODImage Source # 
Ord TCODImage Source # 
Show TCODImage Source # 
Generic TCODImage Source # 

Associated Types

type Rep TCODImage :: * -> * #

type Rep TCODImage Source # 
type Rep TCODImage = D1 (MetaData "TCODImage" "Game.TCOD.Image" "tcod-haskell-0.1.0.0-9JdFGODCf32GFoGmrQ4wdi" True) (C1 (MetaCons "TCODImage" PrefixI True) (S1 (MetaSel (Just Symbol "unTCODImage") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ptr ()))))

imageNew Source #

Arguments

:: Int

Width

-> Int

Height

-> IO TCODImage 

You can create an image of any size, filled with black with this function.

imageFromConsole :: TCODConsole -> IO TCODImage Source #

You can create an image from any console (either the root console or an offscreen console). The image size will depend on the console size and the font characters size. You can then save the image to a file with the save function.

imageRefreshConsole :: TCODImage -> TCODConsole -> IO () Source #

If you need to refresh the image with the console's new content, you don't have to delete it and create another one. Instead, use this function. Note that you must use the same console that was used in the TCOD_image_from_console call (or at least a console with the same size).

imageLoad :: FilePath -> IO TCODImage Source #

You can read data from a .bmp or .png file (for example to draw an image using the background color of the console cells). Note that only 24bits and 32bits PNG files are currently supported.

imageClear :: TCODImage -> Color -> IO () Source #

Filling an image with a color

imageInvert :: TCODImage -> IO () Source #

Inverting the colors of the image

imageHFlip :: TCODImage -> IO () Source #

Flipping the image horizontally

imageVFlip :: TCODImage -> IO () Source #

Flipping the image vertically

imageRotate90 Source #

Arguments

:: TCODImage 
-> Int

Number of rotations

-> IO () 

Rotate the image clockwise by increment of 90 degrees.

imageScale Source #

Arguments

:: TCODImage 
-> Int

New width

-> Int

New height

-> IO () 

Rotate the image clockwise by increment of 90 degrees.

imageSave :: TCODImage -> FilePath -> IO () Source #

You can save an image to a 24 bits .bmp or .png file.

imageGetSize :: TCODImage -> IO (Int, Int) Source #

You can read the size of an image in pixels with this function.

imageGetPixel :: TCODImage -> Int -> Int -> IO Color Source #

You can read the colors from an image with this function.

imageGetAlpha :: TCODImage -> Int -> Int -> IO Int Source #

If you have set a key color for this image with setKeyColor, or if this image was created from a 32 bits PNG file (with alpha layer), you can get the pixel transparency with this function. This function returns a value between 0 (transparent pixel) and 255 (opaque pixel).

imageGetMipmapPixel Source #

Arguments

:: TCODImage 
-> Float

x0

-> Float

y0

-> Float

x1

-> Float

x2

-> IO Color 

This method uses mipmaps to get the average color of an arbitrary rectangular region of the image. It can be used to draw a scaled-down version of the image. It's used by libtcod's blitting functions.

imagePutPixel :: TCODImage -> Int -> Int -> Color -> IO () Source #

Changing the color of a pixel

imageBlit Source #

Arguments

:: TCODImage

the image handler, obtained with the load function.

-> TCODConsole

The console on which the image will be drawn.

-> Float

x Coordinates in the console of the center of the image.

-> Float

y Coordinates in the console of the center of the image.

-> TCODBackgroundFlag

This flag defines how the cell's background color is modified. See TCODBackgroundFlag.

-> Float

scale x Scale coefficient. Must be > 0.0.

-> Float

scale y Scale coefficient. Must be > 0.0.

-> Float

angle Rotation angle in radians.

-> IO () 

Blitting with scaling and/or rotation

This function allows you to specify the floating point coordinates of the center of the image, its scale and its rotation angle.

imageBlitRect Source #

Arguments

:: TCODImage

the image handler, obtained with the load function.

-> TCODConsole

The console on which the image will be drawn.

-> Int

x Coordinates in the console of the upper-left corner of the image.

-> Int

y Coordinates in the console of the upper-left corner of the image.

-> Int

w Dimension of the image on the console. Use -1,-1 to use the image size.

-> Int

h Dimension of the image on the console. Use -1,-1 to use the image size.

-> TCODBackgroundFlag

This flag defines how the cell's background color is modified. See TCODBackgroundFlag.

-> IO () 

This function blits a rectangular part of the image on a console without scaling it or rotating it. Each pixel of the image fills a console cell.

imageBlit2X Source #

Arguments

:: TCODImage

the image handler, obtained with the load function.

-> TCODConsole

The console of which the image will be blited. Foreground, background and character data will be overwritten.

-> Int

dx Coordinate of the console cell where the upper left corner of the blitted image will be.

-> Int

dy Coordinate of the console cell where the upper left corner of the blitted image will be.

-> Int

sx Part of the image to blit. Use -1 in w and h to blit the whole image.

-> Int

sy Part of the image to blit. Use -1 in w and h to blit the whole image.

-> Int

w Part of the image to blit. Use -1 in w and h to blit the whole image.

-> Int

h Part of the image to blit. Use -1 in w and h to blit the whole image.

-> IO () 

Blitting with subcell resolution

Eventually, you can use some special characters in the libtcod fonts to double the console resolution using this blitting function.

imageDelete :: TCODImage -> IO () Source #

Free memory of the image

imageSetKeyColor :: TCODImage -> Color -> IO () Source #

When blitting an image, you can define a key color that will be ignored by the blitting function. This makes it possible to blit non rectangular images or images with transparent pixels.

imageIsPixelTransparent :: TCODImage -> Int -> Int -> IO Bool Source #

You can use this simpler version (for images with alpha layer, returns true only if alpha == 0) :