yapocis.lib.graphics

Low level wrappers around the OpenCL graphics kernels.

Module Contents

Functions

coerce_coords(coords, width, dtype=np.int32)

arrayify1d(scalar_or_vector, length, default=None, dtype=np.float32)

arrayify2d(scalar_or_vector, length, width, default=None, dtype=np.float32)

to_list(scalar, vector, n, default=None)

to_vector(scalar, vector, n, dtype=np.float32, default=None)

coerce_colors(coords, color=None, colors=None, alpha=None, alphas=None, **kwargs) → numpy.ndarray

composite_setup(locations, blocks, alpha=None, alphas=None)

Compute the information for compositing a set of distinct blocks

sprites_setup(locations, sprites, alpha=None, alphas=None)

Compute the information for compositing a set of reusable blocks, for graphical or repeated elements.

lines(image, coords, width=1.0, **kwargs)

rects(image, coords, **kwargs)

circles(image, coords, **kwargs)

triangles(image, coords, **kwargs)

ellipses(image, coords, **kwargs)

composite(image, locations, blocks, **kwargs)

Composite blocks of pixels into target image

sprites(image, locations, sprites, alpha=None, alphas=None)

Composite sprites into target image

setup_texts(locations, texts, font=None, fonts=None, size=None, sizes=None, alpha=None, alphas=None, color=None, colors=None, rotation=None, rotations=None)

draw_strings(image, locations, texts, **kwargs)

yapocis.lib.graphics.coerce_coords(coords, width, dtype=np.int32)[source]
yapocis.lib.graphics.arrayify1d(scalar_or_vector, length, default=None, dtype=np.float32)[source]
yapocis.lib.graphics.arrayify2d(scalar_or_vector, length, width, default=None, dtype=np.float32)[source]
yapocis.lib.graphics.to_list(scalar, vector, n, default=None)[source]
yapocis.lib.graphics.to_vector(scalar, vector, n, dtype=np.float32, default=None)[source]
yapocis.lib.graphics.coerce_colors(coords, color=None, colors=None, alpha=None, alphas=None, **kwargs)numpy.ndarray[source]
yapocis.lib.graphics.composite_setup(locations, blocks, alpha=None, alphas=None)[source]

Compute the information for compositing a set of distinct blocks

Parameters
  • coords – list of tuples composed of a location (x,y)

  • blocks – list of pixel blocks, one per element of coords

  • alpha – list of scalar or vector of opacity

Returns

list of tuples (x,y,block_width,block_height) buffer: float32 array of intensity and opacity per point (2xN) ipixels: index of start of block in buffer

Return type

coords

yapocis.lib.graphics.sprites_setup(locations, sprites, alpha=None, alphas=None)[source]

Compute the information for compositing a set of reusable blocks, for graphical or repeated elements.

Parameters
  • coords – list of tuples composed of a location (isprite, x,y) where isprite is the index into sprites

  • sprites – list of pixel blocks, one per element of coords

  • alpha – list of scalar or vector of opacity

Returns

list of tuples (x,y,block_width,block_height) buffer: float32 array of intensity and opacity per point (2xN) ipixels: index of start of block in buffer

Return type

coords

yapocis.lib.graphics.lines(image, coords, width=1.0, **kwargs)[source]
yapocis.lib.graphics.rects(image, coords, **kwargs)[source]
yapocis.lib.graphics.circles(image, coords, **kwargs)[source]
yapocis.lib.graphics.triangles(image, coords, **kwargs)[source]
yapocis.lib.graphics.ellipses(image, coords, **kwargs)[source]
yapocis.lib.graphics.composite(image, locations, blocks, **kwargs)[source]

Composite blocks of pixels into target image

Parameters
  • image – 2d array of pixels

  • coords – a tuple composed of a location (x,y)

  • blocks – list of pixel blocks

  • alpha – list of scalar or vector of opacity

Returns: None

yapocis.lib.graphics.sprites(image, locations, sprites, alpha=None, alphas=None)[source]

Composite sprites into target image

Parameters
  • image – 2d array of pixels

  • coords – a tuple composed of a location (sprite_index, x,y)

  • blocks – list of sprites blocks

  • alpha – optional list of scalar or vector of opacity

Returns: None

yapocis.lib.graphics.setup_texts(locations, texts, font=None, fonts=None, size=None, sizes=None, alpha=None, alphas=None, color=None, colors=None, rotation=None, rotations=None)[source]
yapocis.lib.graphics.draw_strings(image, locations, texts, **kwargs)[source]