Material

class ember.material.Material(alpha: int)

All materials inherit from this class. This base class should not be instantiated.

UPDATES_EVERY_TICK = False
alpha: int

The transparency of the material, where 0 is fully transparent and 255 is opaque.

abstract render(element: Element, surface: Surface, pos: tuple[int, int], size: tuple[int, int], alpha: int) Surface | None
draw(element: Element, surface: Surface, pos: tuple[int, int], size: tuple[int, int], alpha: int) None
class ember.material.MaterialWithElementCache(alpha: int)

Materials that have an element cache inherit from this class. This base class should not be instantiated.

clear_cache() None
get(element: Element) Surface | None

Returns the cached surface for an element. None is returned if the surface is not yet cached.

render(element: Element, surface: Surface, pos: tuple[int, int], size: tuple[int, int], alpha: int) Surface | None

Render the material to a surface, which is saved in a cache. Returns True if the Surface needed to be re-rendered.

class ember.material.MaterialWithSizeCache(alpha: int)

Materials that have a size cache in addition to an element cache inherit from this class. This base class should not be instantiated.

clear_cache() None
render(element: Element, surface: Surface, pos: tuple[int, int], size: tuple[int, int], alpha: int) Surface | None

Render the material to a surface, which is saved in a cache. Returns True if the Surface needed to be re-rendered.

class ember.material.Blank(*args, **kwargs)
render(element: Element, surface: Surface, pos: tuple[int, int], size: tuple[int, int], alpha: int) Surface | None
class ember.material.Color(color: Color | int | str | tuple[int, int, int] | tuple[int, int, int, int] | Sequence[int], outline: int = 0, alpha: int = 255)

Fills the material area with the specified color.

outline: int

The thickness of the shape outline. If set to 0, the material will be filled with no outline.

set_color(color: Color | int | str | tuple[int, int, int] | tuple[int, int, int, int] | Sequence[int]) None
property color
class ember.material.AverageColor(hsv_adjustment: Sequence[int] = (0, 0, 0), alpha: int = 255)
UPDATES_EVERY_TICK = True
get(element: Element) Surface | None

Returns the cached surface for an element. None is returned if the surface is not yet cached.

class ember.material.Surface(surface: str | Surface, alpha: int = 255)

A pygame Surface wrapped in a Material.

surface: Surface

The surface to render.

render(element: Element, surface: Surface, pos: tuple[int, int], size: tuple[int, int], alpha: int) Surface | None
draw(element: Element, surface: Surface, pos: tuple[int, int], size: tuple[int, int], alpha: int) bool
class ember.material.ScaledSurface(surface: str | Surface, smooth: bool = True, alpha: int = 255)

Stretches a pygame Surface while preserving the edges of the Surface.

smooth: bool

If True, pygame.transform.smoothscale is used. If False, pygame.transform.scale is used.

property surface: Surface

The surface to scale.

class ember.material.RepeatedSurface(surface: str | ~pygame.surface.Surface, content_x: int | ~ember.position.position.Position | None = <Position(50.0% + 0)>, content_y: int | ~ember.position.position.Position | None = <Position(50.0% + 0)>, alpha: int = 255)

Repeats a Pygame Surface to fill the material area

property surface: Surface

The surface to scale.

property content_x: Position
property content_y: Position
class ember.material.StretchedSurface(surface: str | Surface | PathLike, edge: int | Sequence[int] = 5, alpha: int = 255)

Stretches a pygame Surface while preserving the edges of the Surface.

load_surface(surface: str | Surface | PathLike) None
property edge: Sequence[int]
class ember.material.Blur(radius: int = 7, method: ~ember.common.BlurMode | None = <ember.common.BlurMode object>, recalculate_each_tick: bool = False, alpha: int = 255)

Applies a gaussian blur to the material’s area. Experimental.

get(element: Element) Surface | None

Returns the cached surface for an element. None is returned if the surface is not yet cached.

class ember.material.Layered(*materials: Material | Sequence[Material], alpha: int = 255)
render(element: Element, surface: Surface, pos: tuple[int, int], size: tuple[int, int], alpha: int) Surface | None
draw(element: Element, surface: Surface, pos: tuple[int, int], size: tuple[int, int], alpha: int) None

Shapes

class ember.material.shape.Shape(material: Material | None = None, color: Color | int | str | tuple[int, int, int] | tuple[int, int, int, int] | Sequence[int] | None = None, antialias: bool = False, outline: int = 0, alpha: int = 255)

All shape materials inherit from this class. This base class should not be instantiated.

set_outline(outline: int) None

“The thickness of the shape outline. If set to 0, the shape will be filled with no outline.”

set_antialias(value: bool) None

When True, the edges will be anti-aliased.

property outline

The thickness of the shape outline. If set to 0, the shape will be filled with no outline.

property antialias

When True, the edges of the shape will be anti-aliased.

class ember.material.shape.RoundedRect(material: Material | None = None, color: Color | int | str | tuple[int, int, int] | tuple[int, int, int, int] | Sequence[int] | None = None, radius: int = 20, outline: int = 0, antialias: bool = True)
set_radius(radius: int) None
property radius

The corner radius, in pixels, of the rounded rectangle.

class ember.material.shape.Capsule(material: Material | None = None, color: Color | int | str | tuple[int, int, int] | tuple[int, int, int, int] | Sequence[int] | None = None, outline: int = 0, antialias: bool = True)

Masks the given material or color to a capsule (tic-tac) shape.

class ember.material.shape.Ellipse(material: Material | None = None, color: Color | int | str | tuple[int, int, int] | tuple[int, int, int, int] | Sequence[int] | None = None, outline: int = 0, antialias: bool = True)

Masks the given material or color to an ellipse shape.