Operations

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

above(top_graphic: Graphic, bottom_graphic: Graphic) Graphic[source]

Creates a new graphic by placing the two graphics one above the other. The two graphics are horizontally centered.

The pinning position of the new graphic is at its center.

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[source]

Creates a new graphic by placing the two graphics one besides the other. The two graphics are vertically centered.

The pinning position of the new graphic is at its center.

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[source]

Creates a new graphic by composing the two provided graphics. The first graphic is kept in the foreground, the second one in the background. The graphics are aligned by superimposing their pinning positions.

The pinning position used to compose becomes the pinning position of the resulting graphic.

Parameters:
  • foreground_graphic – graphic in the foreground

  • background_graphic – graphic in the background

Returns:

the resulting composed graphic

graphic_height(graphic: Graphic) int[source]

Returns the height of a graphic.

Parameters:

graphic – graphic to calculate the height of

Returns:

height of the graphic

graphic_width(graphic: Graphic) int[source]

Returns the width of a graphic.

Parameters:

graphic – graphic to calculate the width of

Returns:

width of the graphic

overlay(foreground_graphic: Graphic, background_graphic: Graphic) Graphic[source]

Creates a new graphic by overlaying the two provided graphics, keeping the first one in the foreground and the second one in background. The two graphics are overlaid on their centers.

The pinning position of the new graphic is at its center.

Parameters:
  • foreground_graphic – graphic in the foreground

  • background_graphic – graphic in the background

Returns:

the resulting graphic after overlaying the two provided ones

pin(point: Point, graphic: Graphic) Graphic[source]

Creates a new graphic that corresponds to the provided graphic, with a new pinning position.

Each graphic is contained in a rectangular bounding box. There are 9 notable points, corresponding to the four corners of this rectangle, the middle points of the four edges and the center of the rectangle. These points can be referred to using these names: top_left, top_right, bottom_left, bottom_right, top_center, center_right, bottom_center, center_left and center.

Parameters:
  • point – the point indicating the new pinning position

  • graphic – original graphic

Returns:

a new graphic with the specified pinning position

rotate(angle: float, graphic: Graphic) Graphic[source]

Creates a new graphic by rotating counterclockwise the provided graphic around its pinning position by the given angle. A negative angle corresponds to a clockwise rotation.

Parameters:
  • angle – angle of counterclockwise rotation, in degrees

  • graphic – the graphic to rotate

Returns:

a new, rotated graphic