HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulevty-6.6Haskell2010

Graphics.Vty.Image

A Vty program makes Pictures from Images. This module provides the core constructors for creating, combining, and modifying Images.

Contents
  1. Images
  2. Image constructors
  3. Combinators
  4. Image modifications
  5. Character width functions
  6. Display Regions
Synopsis
  • Packagevty-6.6
  • Exports43
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceImage.hs

Images

datadata Image

This is the internal representation of Images. Use the constructors in Graphics.Vty.Image to create instances.

Images are:

  • a horizontal span of text

  • a horizontal or vertical join of two images

  • a two dimensional fill of the Pictures background character

  • a cropped image

  • an empty image of no size or content.

Instances8Eq, Read, Show, Generic, Semigroup, Monoid, …

Image constructors

The empty image. Useful for fold combinators. These occupy no space and do not affect display attributes.

valuechar :: Attr -> Char -> Image

Make an image from a single character. This is a standard Haskell 31-bit character assumed to be in the ISO-10646 encoding.

valuestring :: Attr -> String -> Image

Make an Image from a String.

This is an alias for iso10646String since the usual case is that a literal string like "foo" is represented internally as a list of ISO 10646 31 bit characters.

Note: Keep in mind that GHC will compile source encoded as UTF-8 but the literal strings, while UTF-8 encoded in the source, will be transcoded to a ISO 10646 31 bit characters runtime representation.

Make an image from a string of characters laid out on a single row with the same display attribute. The string is assumed to be a sequence of ISO-10646 characters. The input string should be sanitized of escape sequences (ASCII 27) and carriage returns; otherwise layout and attribute problems may result.

Note: depending on how the Haskell compiler represents string literals, a string literal in a UTF-8 encoded source file, for example, may be represented as a ISO-10646 string. That is, I think, the case with GHC 6.10. This means, for the most part, you don't need to worry about the encoding format when outputting string literals. Just provide the string literal directly to iso10646String or string.

valueutf8String :: Attr -> [Word8] -> Image

Make an Image from a string of characters layed out on a single row. The input is assumed to be the bytes for UTF-8 encoded text.

valuetext :: Attr -> Text -> Image

Make an Image from a lazy text value. The text value should be sanitized of escape sequences (ASCII 27) and carriage returns; otherwise layout and attribute problems may result.

valuetext' :: Attr -> Text -> Image

Make an Image from a text value. The text value should be sanitized of escape sequences (ASCII 27) and carriage returns; otherwise layout and attribute problems may result.

valuecharFill
  1. :: Integral d
  2. => Attr

    The attribute to use.

  3. -> Char

    The character to use in filling the region.

  4. -> d

    The region width.

  5. -> d

    The region height.

  6. -> Image

Make an image filling a region with the specified character.

If either the width or height are less than or equal to 0, then the result is the empty image.

Combinators

valuehorizJoin :: Image -> Image -> Image

combines two images side by side

Combines text chunks where possible. Assures outputWidth and outputHeight properties are not violated.

The result image will have a width equal to the sum of the two images width. And the height will equal the largest height of the two images. The area not defined in one image due to a height mismatch will be filled with the background pattern.

valuevertJoin :: Image -> Image -> Image

combines two images vertically

The result image will have a height equal to the sum of the heights of both images. The width will equal the largest width of the two images. The area not defined in one image due to a width mismatch will be filled with the background pattern.

valuehorizCat :: [Image] -> Image

Compose any number of images together horizontally, with the first in the list being leftmost.

valuevertCat :: [Image] -> Image

Compose any number of images vertically, with the first in the list being topmost.

Image modifications

valuecrop
  1. :: Int

    Cropping width

  2. -> Int

    Cropping height

  3. -> Image

    The image to crop

  4. -> Image

Ensure an image is no larger than the provided size. If the image is larger then crop the right or bottom.

This is equivalent to a vertical crop from the bottom followed by horizontal crop from the right.

valuecropRight :: Int -> Image -> Image

Crop an image's width. If the image's width is less than or equal to the specified width then this operation has no effect. Otherwise the image is cropped from the right.

valuecropLeft :: Int -> Image -> Image

Crop an image's width. If the image's width is less than or equal to the specified width then this operation has no effect. Otherwise the image is cropped from the left.

valuecropBottom :: Int -> Image -> Image

Crop an image's height. If the image's height is less than or equal to the specified height then this operation has no effect. Otherwise the image is cropped from the bottom.

valuecropTop :: Int -> Image -> Image

Crop an image's height. If the image's height is less than or equal to the specified height then this operation has no effect. Otherwise the image is cropped from the top.

valuepad
  1. :: Int

    How much padding to add to the left side of the image.

  2. -> Int

    How much padding to add to the top of the image.

  3. -> Int

    How much padding to add to the right side of the image.

  4. -> Int

    How much padding to add to the bottom of the image.

  5. -> Image

    The image to pad.

  6. -> Image

Pad the given image. This adds background character fills to the left, top, right, bottom.

valueresize :: Int -> Int -> Image -> Image

Generic resize. Pads and crops are added to ensure that the resulting image matches the specified dimensions. This is biased to pad/crop the right and bottom.

valueresizeWidth :: Int -> Image -> Image

Resize the width. Pads and crops as required to assure the given display width. This is biased to pad/crop on the right.

valueresizeHeight :: Int -> Image -> Image

Resize the height. Pads and crops as required to assure the given display height. This is biased to pad/crop on the bottom.

valuetranslate
  1. :: Int

    The horizontal translation offset (can be negative)

  2. -> Int

    The vertical translation offset (can be negative)

  3. -> Image

    The image to translate.

  4. -> Image

Translates an image by padding or cropping the left and top.

If translation offsets are negative then the image is cropped.

Character width functions

valuesafeWcwidth :: Char -> Int

Returns the display width of a character. Assumes all characters with unknown widths are 0 width.

Returns the display width of a string. Assumes all characters with unknown widths are 0 width.

valuesafeWctwidth :: Text -> Int

Returns the display width of a text. Assumes all characters with unknown widths are 0 width.

valuesafeWctlwidth :: Text -> Int

Returns the display width of a lazy text. Assumes all characters with unknown widths are 0 width.

Display Regions