penkit.textures package

Submodules

penkit.textures.util module

The textures.util module contains utility functions for working with textures.

penkit.textures.util.fit_texture(layer)[source]

Fits a layer into a texture by scaling each axis to (0, 1).

Does not preserve aspect ratio (TODO: make this an option).

Parameters:layer (layer) – the layer to scale
Returns:A texture.
Return type:texture
penkit.textures.util.rotate_texture(texture, rotation, x_offset=0.5, y_offset=0.5)[source]

Rotates the given texture by a given angle.

Parameters:
  • texture (texture) – the texture to rotate
  • rotation (float) – the angle of rotation in degrees
  • x_offset (float) – the x component of the center of rotation (optional)
  • y_offset (float) – the y component of the center of rotation (optional)
Returns:

A texture.

Return type:

texture

Module contents

The textures module includes functions to generate textures.

penkit.textures.make_grid_texture(num_h_lines=10, num_v_lines=10, resolution=50)[source]

Makes a texture consisting of a grid of vertical and horizontal lines.

Parameters:
  • num_h_lines (int) – the number of horizontal lines to draw
  • num_v_lines (int) – the number of vertical lines to draw
  • resolution (int) – the number of midpoints to draw on each line
Returns:

A texture.

penkit.textures.make_hex_texture(grid_size=2, resolution=1)[source]

Makes a texture consisting on a grid of hexagons.

Parameters:
  • grid_size (int) – the number of hexagons along each dimension of the grid
  • resolution (int) – the number of midpoints along the line of each hexagon
Returns:

A texture.

penkit.textures.make_lines_texture(num_lines=10, resolution=50)[source]

Makes a texture consisting of a given number of horizontal lines.

Parameters:
  • num_lines (int) – the number of lines to draw
  • resolution (int) – the number of midpoints on each line
Returns:

A texture.

penkit.textures.make_spiral_texture(spirals=6.0, ccw=False, offset=0.0, resolution=1000)[source]

Makes a texture consisting of a spiral from the origin.

Parameters:
  • spirals (float) – the number of rotations to make
  • ccw (bool) – make spirals counter-clockwise (default is clockwise)
  • offset (float) – if non-zero, spirals start offset by this amount
  • resolution (int) – number of midpoints along the spiral
Returns:

A texture.