Skip to content

Class DrawableImage ​

A PNG file, made with Drawable.image.

Extends: Drawable

Drawable.image(spec) takes the same fields by name: the ones below and the shared ones.

  • path is required.
  • Without a width or height, the image keeps its own pixel size on that axis.

A logo in the bottom-right corner of an output:

lua
local logo = Drawable.image({
	path = "/usr/share/pixmaps/archlinux-logo.png",
	right = 16, bottom = 16, width = 64, height = 64, fit = "contain",
})
output.drawables:add(logo)

Properties ​

drawable.path: stringpath ​

The PNG file to show. A relative path is from the config directory.

  • Setting it reads the file straight away.
  • Changes to the file on disk show after the next reload.

Errors when the file is missing or isn't a readable PNG, naming the path. The drawable keeps its old image.

drawable.fit: "stretch" | "contain" | "cover"fit ​

How the image fills its box.

  • Default: "stretch".
  • "stretch": the whole image, squeezed to the box.
  • "contain": the whole image as large as fits, centred.
  • "cover": fills the box, cropping the image's centre to it.