From afe1fb57e33ecb632cce7d84acde4859c75195ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 29 Oct 2020 11:38:22 +0100 Subject: [PATCH] Pygame and paths --- README.md | 20 ++++++++++---------- index.html | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3cd379e..d3f17f2 100644 --- a/README.md +++ b/README.md @@ -1523,7 +1523,7 @@ Open **Opens the file and returns a corresponding file object.** ```python - = open('', mode='r', encoding=None, newline=None) + = open(, mode='r', encoding=None, newline=None) ``` * **`'encoding=None'` means that the default encoding is used, which is platform dependent. Best practice is to use `'encoding="utf-8"'` whenever possible.** * **`'newline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.** @@ -1841,7 +1841,7 @@ SQLite **Opens a connection to the database file. Creates a new file if path doesn't exist.** ```python import sqlite3 - = sqlite3.connect('') # Also ':memory:'. + = sqlite3.connect() # Also ':memory:'. .close() # Closes the connection. ``` @@ -2347,7 +2347,7 @@ from matplotlib import pyplot pyplot.plot( [, label=]) pyplot.plot(, ) pyplot.legend() # Adds a legend. -pyplot.savefig('') # Saves the figure. +pyplot.savefig() # Saves the figure. pyplot.show() # Displays the figure. pyplot.clf() # Clears the figure. ``` @@ -2697,9 +2697,9 @@ from PIL import Image ```python = Image.new('', (width, height)) - = Image.open('') + = Image.open() = .convert('') -.save('') +.save() .show() ``` @@ -2961,9 +2961,9 @@ while all(event.type != pg.QUIT for event in pg.event.get()): ``` ```python - = pg.transform.flip(, xbool, ybool) - = pg.transform.rotate(, degrees) = pg.transform.scale(, (width, height)) + = pg.transform.rotate(, degrees) + = pg.transform.flip(, xbool, ybool) ``` ```python @@ -2976,9 +2976,9 @@ pg.draw.ellipse(, color, ) ### Font ```python - = pg.font.SysFont('', size, bold=False, italic=False) - = pg.font.Font('', size) - = .render(text, antialias, color [, background]) + = pg.font.SysFont('', size) # Loads the system font or default if missing. + = pg.font.Font('', size) # Loads the TTF file. Pass None for default. + = .render(text, antialias, color) # Background color can be specified at the end. ``` ### Sound diff --git a/index.html b/index.html index 24e77a1..a933b48 100644 --- a/index.html +++ b/index.html @@ -1426,7 +1426,7 @@ value = args.<name>
  • Use 'default=<el>' to set the default value.
  • Use 'type=FileType(<mode>)' for files.
  • -

    #Open

    Opens the file and returns a corresponding file object.

    <file> = open('<path>', mode='r', encoding=None, newline=None)
    +

    #Open

    Opens the file and returns a corresponding file object.

    <file> = open(<path>, mode='r', encoding=None, newline=None)
     
    @@ -1659,7 +1659,7 @@ CompletedProcess(args=['bc', #SQLite

    Server-less database engine that stores each database into a separate file.

    Connect

    Opens a connection to the database file. Creates a new file if path doesn't exist.

    import sqlite3
    -<con> = sqlite3.connect('<path>')               # Also ':memory:'.
    +<con> = sqlite3.connect(<path>)                 # Also ':memory:'.
     <con>.close()                                   # Closes the connection.
     
    @@ -2049,7 +2049,7 @@ curses.wrapper(main) pyplot.plot(<y_data> [, label=<str>]) pyplot.plot(<x_data>, <y_data>) pyplot.legend() # Adds a legend. -pyplot.savefig('<path>') # Saves the figure. +pyplot.savefig(<path>) # Saves the figure. pyplot.show() # Displays the figure. pyplot.clf() # Clears the figure. @@ -2318,9 +2318,9 @@ right = [[0.1, 0.6
    <Image> = Image.new('<mode>', (width, height))
    -<Image> = Image.open('<path>')
    +<Image> = Image.open(<path>)
     <Image> = <Image>.convert('<mode>')
    -<Image>.save('<path>')
    +<Image>.save(<path>)
     <Image>.show()
     
    <int/tuple> = <Image>.getpixel((x, y))          # Returns a pixel.
    @@ -2531,9 +2531,9 @@ rect = pg.Rect(240, 2
     <Surf>.set_at((x, y), color)                    # Updates pixel.
     <Surf>.blit(<Surface>, (x, y))                  # Draws passed surface to the surface.
     
    -
    <Surf> = pg.transform.flip(<Surf>, xbool, ybool)
    +
    <Surf> = pg.transform.scale(<Surf>, (width, height))
     <Surf> = pg.transform.rotate(<Surf>, degrees)
    -<Surf> = pg.transform.scale(<Surf>, (width, height))
    +<Surf> = pg.transform.flip(<Surf>, xbool, ybool)
     
    pg.draw.line(<Surf>, color, (x1, y1), (x2, y2), width)
     pg.draw.arc(<Surf>, color, <Rect>, from_radians, to_radians)
    @@ -2541,9 +2541,9 @@ pg.draw.rect(<Surf>, color, <Rect>)
     pg.draw.polygon(<Surf>, color, points)
     pg.draw.ellipse(<Surf>, color, <Rect>)
     
    -

    Font

    <Font> = pg.font.SysFont('<name>', size, bold=False, italic=False)
    -<Font> = pg.font.Font('<path>', size)
    -<Surf> = <Font>.render(text, antialias, color [, background])
    +

    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.
    +<Surf> = <Font>.render(text, antialias, color)  # Background color can be specified at the end.
     

    Sound

    <Sound> = pg.mixer.Sound('<path>')              # Loads the WAV file.