Mercurial > PewPew
changeset 6:6463b8023cc5 draft
Update docs
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sun, 06 Aug 2017 15:47:32 +0200 |
| parents | 0c2fb0e386fa |
| children | 9e7f0f1eb945 |
| files | docs/index.rst docs/pew.rst docs/pewpew.rst |
| diffstat | 3 files changed, 90 insertions(+), 68 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/index.rst Sun Aug 06 14:33:18 2017 +0200 +++ b/docs/index.rst Sun Aug 06 15:47:32 2017 +0200 @@ -10,7 +10,7 @@ :maxdepth: 2 :caption: Contents: - pewpew.rst + pew.rst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/pew.rst Sun Aug 06 15:47:32 2017 +0200 @@ -0,0 +1,89 @@ +PewPew Library Reference +************************ + +.. module:: pew + +.. function:: init() + + Initialize the module. + + This function switches the display on and performs some basic setup. + + +.. function:: brightness(level) + + Set the brightness of the display, from 0 to 15. + + +.. function:: show(pix, dx=0, dy=0) + + Show the provided image on the display, at the specified coordinates. + You will want to call this once for every frame. + + +.. function:: keys() + + Return a number telling which keys have been pressed since the last check. + The number can then be filtered with the ``&`` operator and the ``K_X``, + ``K_DOWN``, ``K_LEFT``, ``K_RIGHT``, ``K_UP``, and ``K_O`` constants to see + whether any of the keys was pressed. + + +.. function:: tick(delay) + + Wait until ``delay`` seconds have passed since the last call to this + function. You can call it every frame to ensure a constant frame rate. + + +.. class:: Pix(width=8, height=8, buffer=None) + + Pix represents a drawing surface, ``width`` pixels wide and ``height`` + pixels high. + + If no ``buffer`` is specified for storing the data, a suitable one will + be automatically created. + + .. classmethod:: from_iter(cls, lines) + + Creates a new Pix and initialzes its contents by iterating over + ``lines`` and then over individual pixels in each line. All the lines + have to be at least as long as the first one. + + .. classmethod:: from_text(cls, text, color=None, background=0, colors=None) + + Creates a new Pix and renders the specified text on it. It is exactly + the size needed to fit the specified text. Newlines and other control + characters are rendered as spaces. + + If ``color`` is not specified, it will use yellow and red for the + letters by default. Otherwise it will use the specified color, with + ``background`` color as the background. + + Alternatively, ``colors`` may be specified as a 4-tuple of colors, + and then the ``color`` and ``background`` arguments are ignored, and + the four specified colors are used for rendering the text. + + .. method:: pixel(self, x, y, color=None) + + If ``color`` is specified, sets the pixel at location ``x``, ``y`` to + that color. If not, returns the color of the pixel at that location. + + If the location is out of bounds of the drawing surface, returns 0. + + .. method:: box(self, color, x=0, y=0, width=self.width, height=self.height) + + Draws a filled box with the specified ``color`` with its top left + corner at the specified location and of the specified size. If no + location and size are specified, fills the whole drawing surface. + + .. method:: blit(self, source, dx=0, dy=0, x=0, y=0, + width=None, height=None, key=None) + + Copied the ``source`` drawing surface onto this surface at location + specified with ``dx`` and ``dy``. + + If ``x``, ``y``, ``widht`` and ``height`` are specified, only copies + that fragment of the ``source`` image, otherwise copies it whole. + + If ``key`` color is specified, that color is considered transparent + on the source image, and is not copied onto this drawing surface.
--- a/docs/pewpew.rst Sun Aug 06 14:33:18 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -PewPew Library Reference -************************ - -.. module:: pewpew - -.. function:: init() - - Initialize the module. - - This function switches the display on. - - -.. function:: brightness(level) - - Set the brightness of the display, from 0 to 15. - - -.. function:: show() - - Update the display, showing any changes that has been made since it was - last updated. You will want to call this once for every frame. - - -.. function:: fill(color) - - Fill the whole display with the specified color. - - -.. function:: pixel(x, y, color=None) - - If ``color`` is specified, sets the pixel at coordinates ``(x, y)`` to that - value. If not, returns the color of the pixel at those coordinates. - - -.. function:: keys() - - Return a number telling which keys have been pressed since the last check. - The number can then be filtered with the ``&`` operator and the ``K_X``, - ``K_DOWN``, ``K_LEFT``, ``K_RIGHT``, ``K_UP``, and ``K_O`` constants to see - whether any of the keys was pressed. - - -.. function:: scroll(dx=0, dy=0, background=0) - - Scroll the contents of the screen by the specified amount horizontally and - vertically. Positive values scroll right/down, negative left/up. The area - uncovered by the scrolling is filled with ``background`` color. - - -.. function:: text(string, x=0, y=0, color=0) - - Display text at the specified location. If ``color`` is 0, use color for - anti-aliasing of the fonts, otherwise render the font in the specified - color. Note that normally only two characters will fit on the screen. - - -.. function:: scroll_text(string, color=0, background=0, y=2) - - An iterator genrator, which scrolls the specified text across the screen, - one pixel per iteration. - - The scrolling starts at the right edge of the screen and continues until - the text disappears. The ``color`` parameter is passed to the ``text`` - function and defines the foreground color of the text. The ``background`` - parameter is passed to the ``scroll`` function and controls the background - color of the text. The ``y`` parameter decides the vertical position on - the screen, and defaults to the center.
