Skip to content

Commit

Permalink
Add some more docstrings and pyi files.
Browse files Browse the repository at this point in the history
  • Loading branch information
corranwebster committed Oct 17, 2024
1 parent b7788d8 commit 7272f38
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/tempe/bitmaps.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

from array import array
from collections.abc import Sequence, Iterable
import framebuf
from typing import Any

from .shapes import ColoredGeometry, Shape, BLIT_KEY_RGB565, point, rectangle


class Bitmaps(Shape):
"""Draw framebuffer bitmaps at points"""

def __init__(
self,
geometry: Iterable[point],
buffers: Iterable[framebuf.FrameBuffer],
*,
key: int | None = None,
palette: Sequence[int] | None = None,
surface: "tempe.surface.Surface | None" = None,
clip: rectangle | None = None,
): ...

def update(
self,
geometry: Iterable[point] | None = None,
buffers: Iterable[framebuf.FrameBuffer] | None = None,
**kwargs: Any,
): ...

def __iter__(self) -> tuple[point, framebuf.FrameBuffer]: ...


class ColoredBitmaps(ColoredGeometry[point]):
"""Draw 1-bit framebuffers bitmaps at points in given colors."""

def __init__(
self,
geometry: Iterable[point],
colors: Iterable[int],
buffers: Iterable[framebuf.FrameBuffer],
*,
surface: "tempe.surface.Surface | None" = None,
clip: rectangle | None = None,
): ...

def update(
self,
geometry: Iterable[point] | None = None,
colors: Iterable[int] | None = None,
buffers: Iterable[framebuf.FrameBuffer] | None = None,
**kwargs: Any,
): ...
3 changes: 3 additions & 0 deletions src/tempe/display.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <[email protected]>
#
# SPDX-License-Identifier: MIT


class Display:
Expand Down
17 changes: 17 additions & 0 deletions src/tempe/display.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <[email protected]>
#
# SPDX-License-Identifier: MIT

"""Base Display class and FileDisplay class.
This module defines the Display abstract base class as well as a concrete
implementation that renders to a binary file.
Users of specific hardware may need to define their own subclasses that
can send updates to the underlying device.
"""

from array import array
from typing import Self

Expand All @@ -10,6 +23,10 @@ class Display:
The array buffer must match the width and height, and the edges
of the bounding rectangle should lie within the Display.
Concrete subclasses must implement this method, either to
directly render partial updates to the underlying device, or to
render to a complete framebuffer which is then rendered.
"""
raise NotImplementedError

Expand Down

0 comments on commit 7272f38

Please sign in to comment.