From d874635756311255efa39c10c8485302ba747d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 1 Mar 2021 13:02:49 +0100 Subject: [PATCH] Introspection, Pygame --- README.md | 24 ++++++++++++------------ index.html | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index c9dc177..e63f1c4 100644 --- a/README.md +++ b/README.md @@ -2158,10 +2158,10 @@ delattr(, '') # Equivalent to `del . = signature() # Signature object of the function. - = .parameters # Dict of function's parameters. - = .name # Prameter's name. - = .kind # Member of ParameterKind enum. + = signature() # Signature object of the function. + = .parameters # Dict of function's Parameter objects. + = .name # Parameter's name. + = .kind # Member of ParameterKind enum. ``` @@ -2965,17 +2965,17 @@ while all(event.type != pg.QUIT for event in pg.event.get()): ``` ```python - = pg.transform.scale(, (width, height)) - = pg.transform.rotate(, degrees) - = pg.transform.flip(, x_bool, y_bool) +import pygame.transform as tr + = tr.scale(, (width, height)) # Returns scaled surface. + = tr.rotate(, degrees) # Returns rotated and scaled surface. + = tr.flip(, x_bool, y_bool) # Returns flipped surface. ``` ```python -pg.draw.line(, color, (x1, y1), (x2, y2), width) -pg.draw.arc(, color, , from_radians, to_radians) -pg.draw.rect(, color, ) -pg.draw.polygon(, color, points) -pg.draw.ellipse(, color, ) +from pygame.draw import line, arc, rect +line(, color, (x1, y1), (x2, y2), width) # Draws a line to the surface. +arc(, color, , from_rad, to_rad) # Also: ellipse(, color, ) +rect(, color, ) # Also: polygon(, color, points) ``` ### Font diff --git a/index.html b/index.html index f94de79..e42ebc3 100644 --- a/index.html +++ b/index.html @@ -1914,10 +1914,10 @@ delattr(<object>, '<attr_name>')

Parameters

from inspect import signature
-<sig>  = signature(<function>)             # Signature object of the function.
-<dict> = <sig>.parameters                  # Dict of function's parameters.
-<str>  = <param>.name                      # Prameter's name.
-<memb> = <param>.kind                      # Member of ParameterKind enum.
+<Sig>  = signature(<function>)             # Signature object of the function.
+<dict> = <Sig>.parameters                  # Dict of function's Parameter objects.
+<str>  = <Param>.name                      # Parameter's name.
+<memb> = <Param>.kind                      # Member of ParameterKind enum.
 

#Metaprograming

Code that generates code.

Type

Type is the root class. If only passed an object it returns its type (class). Otherwise it creates a new class.

<class> = type('<class_name>', <parents_tuple>, <attributes_dict>)
@@ -2546,15 +2546,15 @@ rect = pg.Rect(240, 2 <Surf>.set_at((x, y), color) # Updates pixel. <Surf>.blit(<Surf>, (x, y)) # Draws passed surface to the surface. -
<Surf> = pg.transform.scale(<Surf>, (width, height))
-<Surf> = pg.transform.rotate(<Surf>, degrees)
-<Surf> = pg.transform.flip(<Surf>, x_bool, y_bool)
+
import pygame.transform as tr
+<Surf> = tr.scale(<Surf>, (width, height))      # Returns scaled surface.
+<Surf> = tr.rotate(<Surf>, degrees)             # Returns rotated and scaled surface.
+<Surf> = tr.flip(<Surf>, x_bool, y_bool)        # Returns flipped surface.
 
-
pg.draw.line(<Surf>, color, (x1, y1), (x2, y2), width)
-pg.draw.arc(<Surf>, color, <Rect>, from_radians, to_radians)
-pg.draw.rect(<Surf>, color, <Rect>)
-pg.draw.polygon(<Surf>, color, points)
-pg.draw.ellipse(<Surf>, color, <Rect>)
+
from pygame.draw import line, arc, rect
+line(<Surf>, color, (x1, y1), (x2, y2), width)  # Draws a line to the surface.
+arc(<Surf>, color, <Rect>, from_rad, to_rad)    # Also: ellipse(<Surf>, color, <Rect>)
+rect(<Surf>, color, <Rect>)                     # Also: polygon(<Surf>, color, points)
 

Font

<Font> = pg.font.SysFont('<name>', size)        # Loads the system font or default if missing.
 <Font> = pg.font.Font('<path>', size)           # Loads the TTF file. Pass None for default.