Operations

Functions to do operations on graphics (mainly, to combine them).

above(top_graphic: Graphic, bottom_graphic: Graphic) Graphic

Composes two graphics placing the first on the top and the second on the bottom. The two graphics are aligned horizontally on their centers.

Parameters
  • top_graphic – graphic to place on the top

  • bottom_graphic – graphic to place on the bottom

Returns

the resulting graphic after placing the two graphics one above the other

beside(left_graphic: Graphic, right_graphic: Graphic) Graphic

Composes two graphics placing the first on the left and the second on the right. The two graphics are aligned vertically on their centers.

Parameters
  • left_graphic – graphic to place on the left

  • right_graphic – graphic to place on the right

Returns

the resulting graphic after placing the two graphics one besides the other

compose(foreground_graphic: Graphic, background_graphic: Graphic) Graphic

Composes two graphics keeping the first one in the foreground and the second one in background, aligning them using their pin positions.

The pin location used to compose becomes the pin location of the resulting graphic.

Parameters
  • foreground_graphic – graphic to keep in the foreground

  • background_graphic – graphic to keep in the background

Returns

the resulting graphic after combining the two provided ones

graphic_height(graphic: Graphic) int

Returns the height of a graphic, in pixel.

Parameters

graphic – graphic to calculate the height of

Returns

height of the graphic

graphic_width(graphic: Graphic) int

Returns the width of a graphic, in pixel.

Parameters

graphic – graphic to calculate the width of

Returns

width of the graphic

overlay(foreground_graphic: Graphic, background_graphic: Graphic) Graphic

Overlays two graphics keeping the first one in the foreground and the second one in background, aligning them on their centers.

Parameters
  • foreground_graphic – graphic to keep in the foreground

  • background_graphic – graphic to keep in the background

Returns

the resulting graphic after overlaying the two provided ones

pin(horizontal_place: str, vertical_place: str, graphic: Graphic) Graphic

Changes the pinning position of a graphic, returning a new graphic with the same content but with an updated pinning position.

The new pinning position is determined by the parameters horizontal_place and vertical_place.

Parameters
  • horizontal_place – one of “left”, “middle” or “right” that respectively indicate to move the new pinning positon to the left border, the (horizontal) center, or the right border of the graphic

  • vertical_place – one of “top”, “middle” or “bottom” that respectively indicate to move the new pinning positon to the top border, the (vertical) center, or the bottom border of the graphic

  • graphic – original graphic

Returns

a new graphic with an updated pinning position

rotate(degrees: float, graphic: Graphic) Graphic

Rotates an graphic by a given amount of degrees counterclockwise around its pinning position.

Small rounding errors (due to approximations to the nearest pixel) may occur.

Parameters
  • degrees – amount of degrees the graphic needs to be rotated

  • graphic – the graphic to rotate

Returns

the original graphic rotated around its pinning position