Static functions — GramophoneTools 0.7.0-beta documentation

# Static functions

Functions that work with Frame objects.

Everything related to making LinMaze Frames.

`Frame.` `multi_make`(list_of_frames)

  Renders a list of frames with multiprocessing.

  Parameters

    list_of_frames ([Frame]) – A list of Frame objects that should be rendered.

  Returns

    A list of rendered Frames.

`Frame.` `transition`(left, right, transition_width)

  Takes two 2 dimensional matrices representing a grayscale image and returns them with a smooth transition of given width between them.

  Parameters

    - left (np.array with ndim=2) – The image on the left.

    - right (np.array with ndim=2) – The image on the right.

    - transition_width (int) – The width of the smooth transition.

`Frame.` `combine`(list_of_frames)

  Makes a Frame that is a combination of a list of Frames.

  Parameters

    list_of_frames ([Frame]) – A list of Frame objects without transitions.

  Returns

    Frame

# Abstract Frame classes

Abstract classes for all Frames to inherit from.

## Frame

class `Frame.` `Frame`(width, height, rgb=(1, 1, 1))

  The visual component of the blocks that the mouse navigates in.

  Parameters

    - width (int) – The width of the Frame in pixels.

    - height (int) – The height of the Frame in pixels.

    - rgb ((float, float, float)) – The Red, Green and Blue levels of the Frame.

  static `ext_make`(frame)

    Tries to load the given Frame from cache or makes it and returns the rendered Frame.

  `make`()

    Renders the Frame.

  `make_img`()

    Makes a PIL Image of the Frame.

  `make_texture`()

    Makes the Frame’s texture field that stores RGB data to be used as an OpenGL texture .

  `mirror`()

    Horizontally mirrors the Frame

  `save_img`(filename)

    Saves the bitmap image of the Frame with the given filename.

    Parameters

      filename (str) – The filename the image should be saved as.

  `show_img`()

    Displays the bitmap image of the Frame.

## Random Frame

class `Frame.` `RandomFrame`(width, height, seed)

  Bases: `Frame.Frame`

  Abstract class all randomly generated Frames inherit from.

  Parameters

    seed – The seed of the random number generator

## Wave Frame

class `Frame.` `WaveFrame`(width, height, wavelength, angle)

  Bases: `Frame.Frame`

  Generic grating Frame, for more specific ones to inherit form.

  Parameters

    - wavelength (int) – The wavelength of the grating in pixels, ie. the distance between the middles of the white portions.

    - angle (float) – The angle of the graing where 0 is vertical.

  `make`()

    Renders the Frame.

  static `wave_func`(val)

    Trigonometric function for a sinusoidal wave.

# Specific Frames

All the different types of Frames you can make.

## Binary noise

class `Frame.` `BinaryNoise`(width, height, seed)

  Bases: `Frame.RandomFrame`

  Creates a Frame with noise, that only has black and white pixels

  `make`()

    Renders the Frame.

## Greyscale noise

class `Frame.` `GreyNoise`(width, height, seed)

  Bases: `Frame.RandomFrame`

  Generates a frame with grayscale noise

  `make`()

    Renders the Frame.

## Checkerboard pattern

class `Frame.` `Checkerboard`(width, height, side_length)

  Bases: `Frame.Frame`

  A Frame with a checkerboard pattern.

  Parameters

    side_length (int) – The length of sides of the squares that make up the checkerboard pattern in pixels.

  `make`()

    Renders the Frame.

## Cloud pattern

class `Frame.` `Cloud`(width, height, seed)

  Bases: `Frame.RandomFrame`

  A Frame with a random cloud pattern in it.

  `make`()

    Renders the Frame.

## Marble pattern

class `Frame.` `Marble`(width, height, seed)

  Bases: `Frame.RandomFrame`

  Generates a Frame with a marble pattern.

  `make`()

    Renders the Frame.

## Wood grain pattern

class `Frame.` `Wood`(width, height, seed)

  Bases: `Frame.RandomFrame`

  Generates a Frame with a wood grain pattern.

  `make`()

    Renders the Frame.

## Sine wave modulated grating

class `Frame.` `SineWave`(width, height, wavelength, angle)

  Bases: `Frame.WaveFrame`

  Sine wave modulated grating pattern Frame.

  `make`()

    Renders the Frame.

## Square wave modulated grating

class `Frame.` `SquareWave`(width, height, wavelength, angle)

  Bases: `Frame.WaveFrame`

  Square wave modulated grating pattern Frame.

  `make`()

    Renders the Frame.

## Image file as Frame

class `Frame.` `ImageFile`(height, filename)

  Bases: `Frame.Frame`

  A Frame made from a given image file.

  Parameters

    filename (string) – The name of the file the Frame should be made from.

  `make`()

    Renders the Frame.

  `make_texture`()

    Makes the Frame’s texture field that stores RGB data to be used as an OpenGL texture .