particlepy.shape

class BaseForm(radius: float, color: Tuple[int, int, int], alpha: int = 255, angle: float = 0)[source]

Bases: particlepy.shape.Shape, abc.ABC

The basic form class. Is used as shape argument in particlepy.particle.Particle.

Is subclassed to create other shapes, e.g. Circle or Rect

Parameters
  • radius (float) – Radius of shape

  • color (Tuple[int, int, int]) – Color of shape

  • alpha (int, optional) – Transparency of shape (0 - 255 → RGBA), defaults to 255

  • angle (float, optional) – Degrees of rotation, defaults to 0

Attributes
  • radius (float) – Radius of shape

  • _orig_radius (float) – Radius of shape when being instanced. Property is BaseForm.orig_radius()

  • color (List[int, int, int]) – Color of shape

  • _orig_color (Tuple[int, int, int]) – Color of shape when being instanced. Property is BaseForm.orig_color()

  • alpha (int) – Transparency of shape, ranges from 0 to 255

  • _orig_alpha (int) – Transparency of shape when being instanced. Property is BaseForm.orig_alpha()

  • angle (int) – Degrees of rotation of shape

  • _orig_angle (float) – Angle of shape when being instanced. Property is BaseForm.orig_angle()

  • surface (pygame.Surface) – Pygame surface of shape

  • rect (pygame.Rect) – Pygame Rect of surface. Position does not affect anything

check_size_above_zero()[source]

Checks if surface size is above null

Returns

True if surface size above null, False if otherwise

Return type

bool

decrease(delta: float)[source]

Decreases radius of shape by delta_radius

Parameters

delta (float) – Radius decrease value

get_progress() Tuple[float, float][source]

Returns tuple of two floats: progress and inverted_progress

Returns

progress and inverted_progress

Return type

Tuple[float, float]

make_shape()[source]

Creates shape for shape surface. Can be modified to make different shapes and effects.

make_surface() pygame.Surface[source]

Makes the surface by also calling Shape.make_shape()

Returns

Surface of shape

Return type

pygame.Surface

property orig_color

Returns _orig_color

Returns

_orig_color

Return type

Tuple[int]

property orig_radius

Returns _orig_radius

Returns

_orig_radius

Return type

float

class Circle(radius: float, color: Tuple[int, int, int], alpha: int = 255, angle: float = 0)[source]

Bases: particlepy.shape.BaseForm, abc.ABC

Circle shape class. Is subclass of BaseForm and inherits all attributes and methods

Parameters
  • radius (float) – Radius of shape

  • color (Tuple[int, int, int]) – Color of shape

  • alpha (int, optional) – Transparency of shape (0 - 255 → RGBA), defaults to 255

  • angle (float, optional) – Degrees of rotation, defaults to 0

Attributes
  • radius (float) – Radius of shape

  • _orig_radius (float) – Radius of shape when being instanced. Property is Circle.orig_radius()

  • color (List[int, int, int]) – Color of shape

  • _orig_color (Tuple[int, int, int]) – Color of shape when being instanced. Property is Circle.orig_color()

  • alpha (int) – Transparency of shape, ranges from 0 to 255

  • _orig_alpha (int) – Transparency of shape when being instanced. Property is Circle.orig_alpha()

  • angle (int) – Degrees of rotation of shape

  • _orig_angle (float) – Angle of shape when being instanced. Property is Circle.orig_angle()

  • surface (pygame.Surface) – Pygame surface of shape

  • rect (pygame.Rect) – Pygame Rect of surface. Position does not affect anything

make_shape()[source]

Makes a circle

class Image(surface: pygame.Surface, size: Tuple[int, int], alpha: int = 255, angle: float = 0)[source]

Bases: particlepy.shape.Shape, abc.ABC

Image shape class. Is subclass of Shape and inherits all attributes and methods and adds to it

Parameters
  • surface (pygame.Surface) – Surface of shape

  • size (Tuple[int, int]) – Scaled size of surface

  • alpha (int, optional) – Transparency of shape (0 - 255 → RGBA), defaults to 255

  • angle (float, optional) – Degrees of rotation, defaults to 0

Attributes
  • alpha (int) – Transparency of shape, ranges from 0 to 255

  • _orig_alpha (int) – Transparency of shape when being instanced. Property is Image.orig_alpha()

  • angle (int) – Degrees of rotation of shape

  • _orig_angle (float) – Angle of shape when being instanced. Property is Image.orig_angle()

  • size (List[int, int]) – Scaled size of surface

  • _orig_size (Tuple[int, int]) – Scaled size of surface shape when being instanced. Property is Image.orig_size()

  • surface (pygame.Surface) – Pygame surface of shape

  • _orig_surface (pygame.Surface) – Surface of shape when being instanced. Property is Image.orig_surface()

  • rect (pygame.Rect) – Pygame Rect of surface. Position does not affect anything

check_size_above_zero() bool[source]

Checks if surface size is above null

Returns

True if surface size above null, False if otherwise

Return type

bool

decrease(delta: float)[source]

Decreases size by attr

get_progress() Tuple[float, float][source]

Returns progress and inverted_progress of shape

Returns

progress, inverted_progress

Return type

Tuple[float, float]

make_shape()[source]

Is being called by Image.make_surface() and used to make the visual representation of the shape

make_surface() pygame.Surface[source]

Makes the surface by also calling Image.make_shape()

Returns

Surface of shape

Return type

pygame.Surface

property orig_size

Returns _orig_size

Returns

_orig_size

Return type

Tuple[int, int]

property orig_surface

Returns _orig_surface

Returns

_orig_surface

Return type

Tuple[int, int]

class Rect(radius: float, color: Tuple[int, int, int], alpha: int = 255, angle: float = 0)[source]

Bases: particlepy.shape.BaseForm, abc.ABC

Rectangle shape class. Is subclass of BaseForm and inherits all attributes and methods

Parameters
  • radius (float) – Radius of shape

  • color (Tuple[int, int, int]) – Color of shape

  • alpha (int, optional) – Transparency of shape (0 - 255 → RGBA), defaults to 255

  • angle (float, optional) – Degrees of rotation, defaults to 0

Attributes
  • radius (float) – Radius of shape

  • _orig_radius (float) – Radius of shape when being instanced. Property is Rect.orig_radius()

  • color (List[int, int, int]) – Color of shape

  • _orig_color (Tuple[int, int, int]) – Color of shape when being instanced. Property is Rect.orig_color()

  • alpha (int) – Transparency of shape, ranges from 0 to 255

  • _orig_alpha (int) – Transparency of shape when being instanced. Property is Rect.orig_alpha()

  • angle (int) – Degrees of rotation of shape

  • _orig_angle (float) – Angle of shape when being instanced. Property is Rect.orig_angle()

  • surface (pygame.Surface) – Pygame surface of shape

  • rect (pygame.Rect) – Pygame Rect of surface. Position does not affect anything

make_shape()[source]

Makes a rectangle

class Shape(alpha: int = 255, angle: float = 0)[source]

Bases: object

This is the shape class. It is only used to subclass and use as a base for shapes.

Parameters
  • alpha (int, optional) – Transparency of shape (0 - 255 → RGBA), defaults to 255

  • angle (float, optional) – Degrees of rotation, defaults to 0

Attributes
  • alpha (int) – Transparency of shape, ranges from 0 to 255

  • _orig_alpha (int) – Transparency of shape when being instanced. Property is Shape.orig_alpha()

  • angle (float) – Degrees of rotation

  • _orig_angle (float) – Angle of shape when being instanced. Property is Shape.orig_angle()

check_size_above_zero() bool[source]

Checks if surface size is above null

Returns

True if surface size above null, False if otherwise

Return type

bool

decrease(delta: float)[source]

Decreases size by attr

get_progress() Tuple[float, float][source]

Returns progress and inverted_progress of shape

Returns

progress, inverted_progress

Return type

Tuple[float, float]

make_shape()[source]

Is being called by Shape.make_surface() and used to make the visual representation of the shape

make_surface() pygame.Surface[source]

Makes the surface by also calling Shape.make_shape()

Returns

Surface of shape

Return type

pygame.Surface

property orig_alpha

Returns original alpha

Returns

_orig_alpha

Return type

int

property orig_angle

Returns original angle

Returns

_orig_angle

Return type

float

rotate(surface: pygame.Surface, angle: float)[source]

Rotates shape by angle

Notes

Only exists because of pygame issue 2464.