Erste Version
No files matched your search
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 124 KiB |
|
After Width: | Height: | Size: 125 KiB |
|
After Width: | Height: | Size: 147 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 42 B |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 52 B |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
@@ -0,0 +1,27 @@
|
||||
pygame C API
|
||||
============
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
c_api/slots.rst
|
||||
c_api/base.rst
|
||||
c_api/bufferproxy.rst
|
||||
c_api/color.rst
|
||||
c_api/display.rst
|
||||
c_api/event.rst
|
||||
c_api/freetype.rst
|
||||
c_api/joystick.rst
|
||||
c_api/mixer.rst
|
||||
c_api/rect.rst
|
||||
c_api/rwobject.rst
|
||||
c_api/surface.rst
|
||||
c_api/surflock.rst
|
||||
c_api/version.rst
|
||||
c_api/window.rst
|
||||
|
||||
|
||||
src_c/include/ contains header files for applications
|
||||
that use the pygame C API, while src_c/ contains
|
||||
headers used by pygame internally.
|
||||
@@ -0,0 +1,17 @@
|
||||
File Path Function Arguments
|
||||
============================
|
||||
|
||||
A pygame function or method which takes a file path argument will accept
|
||||
either a Unicode or a byte (8-bit or ASCII character) string.
|
||||
Unicode strings are translated to Python's default filesystem encoding,
|
||||
as returned by sys.getfilesystemencoding(). A Unicode code point
|
||||
above U+FFFF (``\uFFFF``) can be coded directly with a 32-bit escape sequences
|
||||
(``\Uxxxxxxxx``), even for Python interpreters built with an UCS-2
|
||||
(16-bit character) Unicode type. Byte strings are passed
|
||||
to the operating system unchanged.
|
||||
|
||||
Null characters (``\x00``) are not permitted in the path, raising an exception.
|
||||
An exception is also raised if an Unicode file path cannot be encoded.
|
||||
How UTF-16 surrogate codes are handled is Python-interpreter-dependent.
|
||||
Use UTF-32 code points and 32-bit escape sequences instead.
|
||||
The exception types are function-dependent.
|
||||
@@ -0,0 +1,256 @@
|
||||
Pygame-ce Front Page
|
||||
====================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:glob:
|
||||
:hidden:
|
||||
|
||||
ref/*
|
||||
tutorials/en/*
|
||||
tutorials/es/*
|
||||
c_api
|
||||
filepaths
|
||||
logos
|
||||
|
||||
Quick start
|
||||
-----------
|
||||
|
||||
Welcome to pygame-ce! Once you've got pygame-ce installed
|
||||
(:code:`pip install pygame-ce` or :code:`pip3 install pygame-ce` for most
|
||||
people), the next question is how to get a game loop running. Pygame-ce,
|
||||
unlike some other libraries, gives you full control of program
|
||||
execution. That freedom means it is easy to mess up in your initial steps.
|
||||
|
||||
Here is a good example of a basic setup (opens the window, updates the screen, and handles events)--
|
||||
|
||||
.. literalinclude:: ref/code_examples/base_script.py
|
||||
|
||||
Here is a slightly more fleshed out example, which shows you how to move something
|
||||
(a circle in this case) around on screen--
|
||||
|
||||
.. literalinclude:: ref/code_examples/base_script_example.py
|
||||
|
||||
For more in depth reference, check out the :ref:`tutorials-reference-label`
|
||||
section below, or reference the API documentation by module.
|
||||
|
||||
Experimental modules
|
||||
--------------------
|
||||
|
||||
Experimental modules are work in progress, this is why you should refrain from relying on any features
|
||||
provided by these modules, as they are subject to change or removal without prior notice.
|
||||
If you want to test these experimental modules, you might want to understand how you import
|
||||
them, this is how you can do it:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from pygame import experimental_module
|
||||
# Or for specific modules like _sdl2.controller
|
||||
from pygame._sdl2 import controller
|
||||
# Or
|
||||
import pygame.experimental_module
|
||||
|
||||
Don't forget to report us any problem with the experimental features on `github`_ so we can easily
|
||||
turn them to stable API in the future ^^.
|
||||
|
||||
**Below is currently the list of experimental modules :**
|
||||
|
||||
:doc:`ref/geometry`
|
||||
Pygame module for the Circle, Line, and Polygon objects.
|
||||
|
||||
:doc:`ref/sdl2_controller`
|
||||
Pygame module to work with controllers.
|
||||
|
||||
:doc:`ref/sdl2_video`
|
||||
Pygame module for porting new SDL video systems.
|
||||
|
||||
.. _github: https://github.com/pygame-community/pygame-ce
|
||||
|
||||
Documents
|
||||
---------
|
||||
|
||||
`Readme`_
|
||||
Basic information about pygame: what it is, who is involved, and where to find it.
|
||||
|
||||
:doc:`filepaths`
|
||||
How pygame handles file system paths.
|
||||
|
||||
:doc:`Pygame Logos <logos>`
|
||||
The logos of Pygame in different resolutions.
|
||||
|
||||
|
||||
`LGPL License`_
|
||||
This is the license pygame is distributed under.
|
||||
It provides for pygame to be distributed with open source and commercial software.
|
||||
Generally, if pygame is not changed, it can be used with any type of program.
|
||||
|
||||
.. _tutorials-reference-label:
|
||||
|
||||
Tutorials
|
||||
---------
|
||||
|
||||
| `Master Python by making 5 games [the new ultimate introduction to pygame] <https://www.youtube.com/watch?v=8OMghdHP-zs>`_
|
||||
| YouTube video by Clear Code.
|
||||
|
||||
| `Pygame in 18 Minutes <https://www.youtube.com/watch?v=blLLtdv4tvo>`_
|
||||
| YouTube video by DaFluffyPotato.
|
||||
|
||||
| `Introduction to Pygame-ce, 2D game programming <https://github.com/adamsralf/pygame_book/blob/main/00%20pygamece.pdf>`_
|
||||
| Book by Ralf Adams.
|
||||
|
||||
:doc:`Newbie Guide <tutorials/en/newbie-guide>`
|
||||
A list of thirteen helpful tips for people to get comfortable using pygame.
|
||||
|
||||
:doc:`Import and Initialize <tutorials/en/import-init>`
|
||||
The beginning steps on importing and initializing pygame.
|
||||
The pygame package is made of several modules.
|
||||
Some modules are not included on all platforms.
|
||||
|
||||
:doc:`How do I move an Image? <tutorials/en/move-it>`
|
||||
A basic tutorial that covers the concepts behind 2D computer animation.
|
||||
Information about drawing and clearing objects to make them appear animated.
|
||||
|
||||
:doc:`Chimp Tutorial, Line by Line <tutorials/en/chimp-explanation>`
|
||||
The pygame examples include a simple program with an interactive fist and a chimpanzee.
|
||||
This was inspired by the annoying flash banner of the early 2000s.
|
||||
This tutorial examines every line of code used in the example.
|
||||
|
||||
:doc:`What is Premultiplied Alpha? <tutorials/en/premultiplied-alpha>`
|
||||
An explanation of alpha compositing and the advantages of using premultiplied alpha.
|
||||
|
||||
:doc:`Sprite Module Introduction <tutorials/en/intro-to-sprites>`
|
||||
Pygame includes a higher level sprite module to help organize games.
|
||||
The sprite module includes several classes that help manage details found in almost all games types.
|
||||
The Sprite classes are a bit more advanced than the regular pygame modules,
|
||||
and need more understanding to be properly used.
|
||||
|
||||
:doc:`Introduction to Pygame <tutorials/en/intro-to-pygame>`
|
||||
An introduction to the basics of pygame.
|
||||
This is written for users of Python and appeared in volume two of the Py magazine.
|
||||
|
||||
:doc:`Surfarray Introduction <tutorials/en/intro-to-surfarray>`
|
||||
Pygame used the NumPy python module to allow efficient per pixel effects on images.
|
||||
Using the surface arrays is an advanced feature that allows custom effects and filters.
|
||||
This also examines some of the simple effects from the pygame example, arraydemo.py.
|
||||
|
||||
:doc:`Camera Module Introduction <tutorials/en/intro-to-camera>`
|
||||
Pygame, as of 1.9, has a camera module that allows you to capture images,
|
||||
watch live streams, and do some basic computer vision.
|
||||
This tutorial covers those use cases.
|
||||
|
||||
:doc:`Making Games Tutorial <tutorials/en/make-games>`
|
||||
A large tutorial that covers the bigger topics needed to create an entire game.
|
||||
|
||||
:doc:`Display Modes <tutorials/en/display-modes>`
|
||||
Getting a display surface for the screen.
|
||||
|
||||
:doc:`Tutorial de Pygame - Ejemplo del Chimpancé, Línea Por Línea <tutorials/es/ChimpanceLineaporLinea>`
|
||||
Los ejemplos de pygame incluyen un sencillo programa con un puño interactivo y un chimpancé.
|
||||
Está inspirado en el molesto banner de flash de principios de la década de 2000.
|
||||
Este tutorial examina cada línea de código utilizada en el ejemplo.
|
||||
|
||||
Reference
|
||||
---------
|
||||
|
||||
:ref:`genindex`
|
||||
A list of all functions, classes, and methods in the pygame package.
|
||||
|
||||
:doc:`ref/bufferproxy`
|
||||
An array protocol view of surface pixels
|
||||
|
||||
:doc:`ref/color`
|
||||
Color representation.
|
||||
|
||||
:doc:`ref/cursors`
|
||||
Loading and compiling cursor images.
|
||||
|
||||
:doc:`ref/display`
|
||||
Configure the display surface.
|
||||
|
||||
:doc:`ref/draw`
|
||||
Drawing simple shapes like lines and ellipses to surfaces.
|
||||
|
||||
:doc:`ref/event`
|
||||
Manage the incoming events from various input devices and the windowing platform.
|
||||
|
||||
:doc:`ref/examples`
|
||||
Various programs demonstrating the use of individual pygame modules.
|
||||
|
||||
:doc:`ref/font`
|
||||
Loading and rendering TrueType fonts.
|
||||
|
||||
:doc:`ref/freetype`
|
||||
Enhanced pygame module for loading and rendering font faces.
|
||||
|
||||
:doc:`ref/gfxdraw`
|
||||
Anti-aliasing draw functions.
|
||||
|
||||
:doc:`ref/image`
|
||||
Loading, saving, and transferring of surfaces.
|
||||
|
||||
:doc:`ref/joystick`
|
||||
Manage the joystick devices.
|
||||
|
||||
:doc:`ref/key`
|
||||
Manage the keyboard device.
|
||||
|
||||
:doc:`ref/locals`
|
||||
Pygame constants.
|
||||
|
||||
:doc:`ref/mixer`
|
||||
Load and play sounds
|
||||
|
||||
:doc:`ref/mouse`
|
||||
Manage the mouse device and display.
|
||||
|
||||
:doc:`ref/music`
|
||||
Play streaming music tracks.
|
||||
|
||||
:doc:`ref/pygame`
|
||||
Top level functions to manage pygame.
|
||||
|
||||
:doc:`ref/pixelarray`
|
||||
Manipulate image pixel data.
|
||||
|
||||
:doc:`ref/rect`
|
||||
Flexible container for a rectangle.
|
||||
|
||||
:doc:`ref/scrap`
|
||||
Native clipboard access.
|
||||
|
||||
:doc:`ref/sndarray`
|
||||
Manipulate sound sample data.
|
||||
|
||||
:doc:`ref/sprite`
|
||||
Higher level objects to represent game images.
|
||||
|
||||
:doc:`ref/surface`
|
||||
Objects for images and the screen.
|
||||
|
||||
:doc:`ref/surfarray`
|
||||
Manipulate image pixel data.
|
||||
|
||||
:doc:`ref/tests`
|
||||
Test pygame.
|
||||
|
||||
:doc:`ref/time`
|
||||
Manage timing and framerate.
|
||||
|
||||
:doc:`ref/transform`
|
||||
Resize and move images.
|
||||
|
||||
:doc:`ref/typing`
|
||||
Provide common typehints
|
||||
|
||||
:doc:`ref/window`
|
||||
Pygame object that handles a window.
|
||||
|
||||
:doc:`pygame C API <c_api>`
|
||||
The C api shared amongst pygame extension modules.
|
||||
|
||||
:ref:`search`
|
||||
Search pygame documents by keyword.
|
||||
|
||||
.. _Readme: https://github.com/pygame-community/pygame-ce#readme
|
||||
|
||||
.. _LGPL License: LGPL.txt
|
||||
@@ -0,0 +1,58 @@
|
||||
*************************************************
|
||||
Pygame CE Logos Page
|
||||
*************************************************
|
||||
|
||||
Pygame CE Logos
|
||||
===============
|
||||
|
||||
These logos are available for use in your own game projects.
|
||||
Please put them up wherever you see fit.
|
||||
|
||||
The pygame-ce logo and its variants were created by Mega-JC and kadir014 on June 30, 2024.
|
||||
|
||||
.. container:: fullwidth
|
||||
|
||||
.. image:: _static/pygame_ce_logo.webp
|
||||
|
||||
| `pygame_ce_logo.svg <_static/pygame_ce_logo.svg>`_
|
||||
| `pygame_ce_logo.webp <_static/pygame_ce_logo.webp>`_ - 1560 x 800
|
||||
|
||||
.. image:: _static/pygame_ce_lofi.webp
|
||||
|
||||
| `pygame_ce_lofi.svg <_static/pygame_ce_lofi.svg>`_
|
||||
| `pygame_ce_lofi.webp <_static/pygame_ce_lofi.webp>`_ - 1560 x 800
|
||||
|
||||
.. image:: _static/pygame_ce_powered.webp
|
||||
|
||||
| `pygame_ce_powered.svg <_static/pygame_ce_powered.svg>`_
|
||||
| `pygame_ce_powered.webp <_static/pygame_ce_powered.webp>`_ - 1560 x 824
|
||||
|
||||
.. image:: _static/pygame_ce_tiny.webp
|
||||
|
||||
| `pygame_ce_tiny.webp <_static/pygame_ce_tiny.webp>`_ - 214 x 110
|
||||
|
||||
.. image:: _static/pygame_ce_powered_lowres.webp
|
||||
|
||||
| `pygame_ce_powered_lowres.webp <_static/pygame_ce_powered_lowres.webp>`_ - 101 x 53
|
||||
|
||||
|
||||
|
||||
Upstream & legacy logos
|
||||
-----------------------
|
||||
|
||||
The pygame logo was originally created
|
||||
by TheCorruptor on July 29, 2001.
|
||||
|
||||
It was upscaled alongside its "LoFi" and "Powered" variants by Mega-JC on
|
||||
August 29, 2021.
|
||||
|
||||
.. container:: fullwidth
|
||||
|
||||
| `upstream_logos.zip <_static/upstream_logos.zip>`_ - 314 KB
|
||||
|
||||
There is a higher resolution layered photoshop image
|
||||
available `here <https://www.pygame.org/ftp/pygame_ce_logo.psd>`_. *(1.3 MB)*
|
||||
|
||||
.. container:: fullwidth
|
||||
|
||||
| `legacy_logos.zip <_static/legacy_logos.zip>`_ - 50.1 KB
|
||||
@@ -0,0 +1,113 @@
|
||||
.. include:: common.txt
|
||||
|
||||
.. default-domain:: py
|
||||
|
||||
:class:`pygame.BufferProxy`
|
||||
===========================
|
||||
|
||||
.. currentmodule:: pygame
|
||||
|
||||
.. class:: BufferProxy
|
||||
|
||||
| :sl:`pygame object to export a surface buffer through an array protocol`
|
||||
| :sg:`BufferProxy(parent) -> BufferProxy`
|
||||
|
||||
:class:`BufferProxy` is a pygame support type, designed as the return value
|
||||
of the :meth:`Surface.get_buffer` and :meth:`Surface.get_view` methods.
|
||||
For all Python versions a :class:`BufferProxy` object exports a C struct
|
||||
and Python level array interface on behalf of its parent object's buffer.
|
||||
A new buffer interface is also exported.
|
||||
In pygame, :class:`BufferProxy` is key to implementing the
|
||||
:mod:`pygame.surfarray` module.
|
||||
|
||||
:class:`BufferProxy` instances can be created directly from Python code,
|
||||
either for a parent that exports an interface, or from a Python ``dict``
|
||||
describing an object's buffer layout. The dict entries are based on the
|
||||
Python level array interface mapping. The following keys are recognized:
|
||||
|
||||
``"shape"`` : tuple
|
||||
The length of each array dimension as a tuple of integers. The
|
||||
length of the tuple is the number of dimensions in the array.
|
||||
|
||||
``"typestr"`` : string
|
||||
The array element type as a length 3 string. The first character
|
||||
gives byteorder, '<' for little-endian, '>' for big-endian, and
|
||||
'\|' for not applicable. The second character is the element type,
|
||||
'i' for signed integer, 'u' for unsigned integer, 'f' for floating
|
||||
point, and 'V' for an chunk of bytes. The third character gives the
|
||||
bytesize of the element, from '1' to '9' bytes. So, for example,
|
||||
"<u4" is an unsigned 4 byte little-endian integer, such as a
|
||||
32 bit pixel on a PC, while "\|V3" would represent a 24 bit pixel,
|
||||
which has no integer equivalent.
|
||||
|
||||
``"data"`` : tuple
|
||||
The physical buffer start address and a read-only flag as a length
|
||||
2 tuple. The address is an integer value, while the read-only flag
|
||||
is a bool—``False`` for writable, ``True`` for read-only.
|
||||
|
||||
``"strides"`` : tuple : (optional)
|
||||
Array stride information as a tuple of integers. It is required
|
||||
only of non C-contiguous arrays. The tuple length must match
|
||||
that of ``"shape"``.
|
||||
|
||||
``"parent"`` : object : (optional)
|
||||
The exporting object. It can be used to keep the parent object
|
||||
alive while its buffer is visible.
|
||||
|
||||
``"before"`` : callable : (optional)
|
||||
Callback invoked when the :class:`BufferProxy` instance
|
||||
exports the buffer. The callback is given one argument, the
|
||||
``"parent"`` object if given, otherwise ``None``.
|
||||
The callback is useful for setting a lock on the parent.
|
||||
|
||||
``"after"`` : callable : (optional)
|
||||
Callback invoked when an exported buffer is released.
|
||||
The callback is passed on argument, the ``"parent"`` object if given,
|
||||
otherwise None. The callback is useful for releasing a lock on the
|
||||
parent.
|
||||
|
||||
The BufferProxy class supports subclassing, instance variables, and weak
|
||||
references.
|
||||
|
||||
.. versionaddedold:: 1.8.0
|
||||
.. versionextendedold:: 1.9.2
|
||||
|
||||
.. attribute:: parent
|
||||
|
||||
| :sl:`Return wrapped exporting object.`
|
||||
| :sg:`parent -> Surface`
|
||||
| :sg:`parent -> parent`
|
||||
|
||||
The :class:`Surface` which returned the :class:`BufferProxy` object or
|
||||
the object passed to a :class:`BufferProxy` call.
|
||||
|
||||
.. attribute:: length
|
||||
|
||||
| :sl:`The size, in bytes, of the exported buffer.`
|
||||
| :sg:`length -> int`
|
||||
|
||||
The number of valid bytes of data exported. For discontinuous data,
|
||||
that is data which is not a single block of memory, the bytes within
|
||||
the gaps are excluded from the count. This property is equivalent to
|
||||
the ``Py_buffer`` C struct ``len`` field.
|
||||
|
||||
.. attribute:: raw
|
||||
|
||||
| :sl:`A copy of the exported buffer as a single block of bytes.`
|
||||
| :sg:`raw -> bytes`
|
||||
|
||||
The buffer data as a ``str``/``bytes`` object.
|
||||
Any gaps in the exported data are removed.
|
||||
|
||||
.. method:: write
|
||||
|
||||
| :sl:`Write raw bytes to object buffer.`
|
||||
| :sg:`write(buffer, offset=0)`
|
||||
|
||||
Overwrite bytes in the parent object's data. The data must be C or F
|
||||
contiguous, otherwise a ValueError is raised. Argument `buffer` is a
|
||||
``str``/``bytes`` object. An optional offset gives a
|
||||
start position, in bytes, within the buffer where overwriting begins.
|
||||
If the offset is negative or greater that or equal to the buffer proxy's
|
||||
:attr:`length` value, an ``IndexException`` is raised.
|
||||
If ``len(buffer) > proxy.length + offset``, a ``ValueError`` is raised.
|
||||
@@ -0,0 +1,246 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.camera`
|
||||
====================
|
||||
|
||||
.. module:: pygame.camera
|
||||
:synopsis: pygame module for camera use
|
||||
|
||||
| :sl:`pygame module for camera use`
|
||||
|
||||
Pygame currently supports Linux (V4L2) and Windows (MSMF) cameras natively,
|
||||
with wider platform support available via an integrated OpenCV backend.
|
||||
|
||||
.. versionaddedold:: 2.0.2 Windows native camera support
|
||||
.. versionaddedold:: 2.0.3 New OpenCV backends
|
||||
.. versionchanged:: 2.3.0 Removed deprecated vidcapture backend
|
||||
|
||||
EXPERIMENTAL!: This API may change or disappear in later pygame releases. If
|
||||
you use this, your code will very likely break with the next pygame release.
|
||||
|
||||
The Bayer to ``RGB`` function is based on:
|
||||
|
||||
::
|
||||
|
||||
Sonix SN9C101 based webcam basic I/F routines
|
||||
Copyright (C) 2004 Takafumi Mizuno <taka-qce@ls-a.jp>
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
.. versionaddedold:: 1.9.0
|
||||
|
||||
.. function:: init
|
||||
|
||||
| :sl:`Module init`
|
||||
| :sg:`init(backend = None) -> None`
|
||||
|
||||
This function starts up the camera module, choosing the best webcam backend
|
||||
it can find for your system. This is not guaranteed to succeed, and may even
|
||||
attempt to import third party modules, like `OpenCV`. If you want to
|
||||
override its backend choice, you can call pass the name of the backend you
|
||||
want into this function. More about backends in
|
||||
:func:`get_backends()`.
|
||||
|
||||
.. versionchangedold:: 2.0.3 Option to explicitly select backend
|
||||
|
||||
.. ## pygame.camera.init ##
|
||||
|
||||
.. function:: get_backends
|
||||
|
||||
| :sl:`Get the backends supported on this system`
|
||||
| :sg:`get_backends() -> [str]`
|
||||
|
||||
This function returns every backend it thinks has a possibility of working
|
||||
on your system, in order of priority.
|
||||
|
||||
pygame.camera Backends:
|
||||
::
|
||||
|
||||
Backend OS Description
|
||||
---------------------------------------------------------------------------------
|
||||
_camera (MSMF) Windows Builtin, works on Windows 8+ Python3
|
||||
_camera (V4L2) Linux Builtin
|
||||
OpenCV Any Uses `opencv-python` module, can't enumerate cameras
|
||||
OpenCV-Mac Mac Same as OpenCV, but has camera enumeration
|
||||
|
||||
There are two main differences among backends.
|
||||
|
||||
The _camera backends are built in to pygame itself, and require no third
|
||||
party imports. All the other backends do. For the OpenCV backend,
|
||||
the module will need to be installed on your system.
|
||||
|
||||
The other big difference is "camera enumeration." Some backends don't have
|
||||
a way to list out camera names, or even the number of cameras on the
|
||||
system. In these cases, :func:`list_cameras()` will return
|
||||
something like ``[0]``. If you know you have multiple cameras on the
|
||||
system, these backend ports will pass through a "camera index number"
|
||||
through if you use that as the ``device`` parameter.
|
||||
|
||||
.. versionaddedold:: 2.0.3
|
||||
|
||||
.. ## pygame.camera.get_backends ##
|
||||
|
||||
.. function:: colorspace
|
||||
|
||||
| :sl:`Surface colorspace conversion`
|
||||
| :sg:`colorspace(surface, format, dest_surface = None, /) -> Surface`
|
||||
|
||||
Allows for conversion from "RGB" to a destination colorspace of "HSV" or
|
||||
"YUV". The source and destination surfaces must be the same size and pixel
|
||||
depth. This is useful for computer vision on devices with limited processing
|
||||
power. Capture as small of an image as possible, ``transform.scale()`` it
|
||||
even smaller, and then convert the colorspace to ``YUV`` or ``HSV`` before
|
||||
doing any processing on it.
|
||||
|
||||
.. ## pygame.camera.colorspace ##
|
||||
|
||||
.. function:: list_cameras
|
||||
|
||||
| :sl:`returns a list of available cameras`
|
||||
| :sg:`list_cameras() -> [cameras]`
|
||||
|
||||
Checks the computer for available cameras and returns a list of strings of
|
||||
camera names, ready to be fed into :class:`pygame.camera.Camera`.
|
||||
|
||||
If the camera backend doesn't support webcam enumeration, this will return
|
||||
something like ``[0]``. See :func:`get_backends()` for much more
|
||||
information.
|
||||
|
||||
.. ## pygame.camera.list_cameras ##
|
||||
|
||||
.. class:: Camera
|
||||
|
||||
| :sl:`load a camera`
|
||||
| :sg:`Camera(device, (width, height), format) -> Camera`
|
||||
|
||||
Loads a camera. On Linux, the device is typically something like
|
||||
"/dev/video0". Default width and height are 640 by 480.
|
||||
Format is the desired colorspace of the output.
|
||||
This is useful for computer vision purposes. The default is
|
||||
``RGB``. The following are supported:
|
||||
|
||||
* ``RGB`` - Red, Green, Blue
|
||||
|
||||
* ``YUV`` - Luma, Blue Chrominance, Red Chrominance
|
||||
|
||||
* ``HSV`` - Hue, Saturation, Value
|
||||
|
||||
.. method:: start
|
||||
|
||||
| :sl:`opens, initializes, and starts capturing`
|
||||
| :sg:`start() -> None`
|
||||
|
||||
Opens the camera device, attempts to initialize it, and begins recording
|
||||
images to a buffer. The camera must be started before any of the below
|
||||
functions can be used.
|
||||
|
||||
.. ## Camera.start ##
|
||||
|
||||
.. method:: stop
|
||||
|
||||
| :sl:`stops, uninitializes, and closes the camera`
|
||||
| :sg:`stop() -> None`
|
||||
|
||||
Stops recording, uninitializes the camera, and closes it. Once a camera
|
||||
is stopped, the below functions cannot be used until it is started again.
|
||||
|
||||
.. ## Camera.stop ##
|
||||
|
||||
.. method:: get_controls
|
||||
|
||||
| :sl:`gets current values of user controls`
|
||||
| :sg:`get_controls() -> (hflip = bool, vflip = bool, brightness)`
|
||||
|
||||
If the camera supports it, get_controls will return the current settings
|
||||
for horizontal and vertical image flip as bools and brightness as an int.
|
||||
If unsupported, it will return the default values of (0, 0, 0). Note that
|
||||
the return values here may be different than those returned by
|
||||
set_controls, though these are more likely to be correct.
|
||||
|
||||
.. ## Camera.get_controls ##
|
||||
|
||||
.. method:: set_controls
|
||||
|
||||
| :sl:`changes camera settings if supported by the camera`
|
||||
| :sg:`set_controls(hflip = bool, vflip = bool, brightness) -> (hflip = bool, vflip = bool, brightness)`
|
||||
|
||||
Allows you to change camera settings if the camera supports it. The
|
||||
return values will be the input values if the camera claims it succeeded
|
||||
or the values previously in use if not. Each argument is optional, and
|
||||
the desired one can be chosen by supplying the keyword, like hflip. Note
|
||||
that the actual settings being used by the camera may not be the same as
|
||||
those returned by set_controls. On Windows, :code:`hflip` and :code:`vflip` are
|
||||
implemented by pygame, not by the Camera, so they should always work, but
|
||||
:code:`brightness` is unsupported.
|
||||
|
||||
.. ## Camera.set_controls ##
|
||||
|
||||
.. method:: get_size
|
||||
|
||||
| :sl:`returns the dimensions of the images being recorded`
|
||||
| :sg:`get_size() -> (width, height)`
|
||||
|
||||
Returns the current dimensions of the images being captured by the
|
||||
camera. This will return the actual size, which may be different than the
|
||||
one specified during initialization if the camera did not support that
|
||||
size.
|
||||
|
||||
.. ## Camera.get_size ##
|
||||
|
||||
.. method:: query_image
|
||||
|
||||
| :sl:`checks if a frame is ready`
|
||||
| :sg:`query_image() -> bool`
|
||||
|
||||
If an image is ready to get, it returns true. Otherwise it returns false.
|
||||
Note that some webcams will always return False and will only queue a
|
||||
frame when called with a blocking function like :func:`get_image()`.
|
||||
On Windows (MSMF), and the OpenCV backends, :func:`query_image()`
|
||||
should be reliable, though. This is useful to separate the framerate of
|
||||
the game from that of the camera without having to use threading.
|
||||
|
||||
.. ## Camera.query_image ##
|
||||
|
||||
.. method:: get_image
|
||||
|
||||
| :sl:`captures an image as a Surface`
|
||||
| :sg:`get_image(Surface = None, /) -> Surface`
|
||||
|
||||
Pulls an image off of the buffer as an ``RGB`` Surface. It can optionally
|
||||
reuse an existing Surface to save time. The bit-depth of the surface is
|
||||
24 bits on Linux, 32 bits on Windows, or the same as the optionally
|
||||
supplied Surface.
|
||||
|
||||
.. ## Camera.get_image ##
|
||||
|
||||
.. method:: get_raw
|
||||
|
||||
| :sl:`returns an unmodified image as bytes`
|
||||
| :sg:`get_raw() -> bytes`
|
||||
|
||||
Gets an image from a camera as a string in the native pixelformat of the
|
||||
camera. Useful for integration with other libraries. This returns a
|
||||
bytes object
|
||||
|
||||
.. ## Camera.get_raw ##
|
||||
|
||||
.. ## pygame.camera.Camera ##
|
||||
|
||||
.. ## pygame.camera ##
|
||||
@@ -0,0 +1,9 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.Color`
|
||||
===================
|
||||
|
||||
.. currentmodule:: pygame
|
||||
|
||||
.. autopgclass:: Color
|
||||
:members:
|
||||
@@ -0,0 +1,11 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.cursors`
|
||||
=====================
|
||||
|
||||
.. autopgmodule:: pygame.cursors
|
||||
:members:
|
||||
|
||||
Example code for creating and settings cursors. (Click the mouse to switch cursor)
|
||||
|
||||
.. literalinclude:: code_examples/cursors_module_example.py
|
||||
@@ -0,0 +1,7 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.display`
|
||||
=====================
|
||||
|
||||
.. autopgmodule:: pygame.display
|
||||
:members:
|
||||
@@ -0,0 +1,14 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.draw`
|
||||
==================
|
||||
|
||||
.. autopgmodule:: pygame.draw
|
||||
:members:
|
||||
|
||||
.. figure:: code_examples/draw_module_example.png
|
||||
:alt: draw module example
|
||||
|
||||
Example code for draw module.
|
||||
|
||||
.. literalinclude:: code_examples/draw_module_example.py
|
||||
@@ -0,0 +1,524 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.event`
|
||||
===================
|
||||
|
||||
.. module:: pygame.event
|
||||
:synopsis: pygame module for interacting with events and queues
|
||||
|
||||
| :sl:`pygame module for interacting with events and queues`
|
||||
|
||||
.. rubric:: Event queue
|
||||
|
||||
Pygame handles all its event messaging through an event queue. The functions in
|
||||
this module help you manage that event queue. The input queue is heavily
|
||||
dependent on the video system (:mod:`pygame.display` or :class:`pygame.Window`).
|
||||
If a window has not been created, the event queue may not work properly.
|
||||
|
||||
The event queue has an upper limit on the number of events it can hold. When
|
||||
the queue becomes full new events are quietly dropped. To prevent lost events,
|
||||
especially input events which signal a quit command, your program must handle
|
||||
events every frame (with :func:`pygame.event.get()`, :func:`pygame.event.pump()`,
|
||||
:func:`pygame.event.wait()`, :func:`pygame.event.peek()` or
|
||||
:func:`pygame.event.clear()`).
|
||||
|
||||
.. note:: Not handling events may cause the system to decide the program is
|
||||
frozen (not responding).
|
||||
|
||||
.. rubric:: Events of input devices
|
||||
|
||||
To get the state of various input devices, you can forego the event queue and
|
||||
access the input devices directly with their appropriate modules:
|
||||
:mod:`pygame.mouse`, :mod:`pygame.key`, and :mod:`pygame.joystick`. However,
|
||||
the event queue still needs to be running internally to enable this; programs
|
||||
still need to use functions like :func:`pygame.event.get()` or
|
||||
:func:`pygame.event.pump()` periodically. Note: Joysticks will not send any
|
||||
events until the device has been initialized.
|
||||
|
||||
.. rubric:: Event objects
|
||||
|
||||
The event queue contains :class:`pygame.event.Event` event objects.
|
||||
There are a variety of ways to access the queued events, from simply
|
||||
checking for the existence of events, to popping them off of the event queue.
|
||||
|
||||
All :class:`pygame.event.Event` instances contain an event type identifier
|
||||
and attributes specific to that event type. The event type identifier is
|
||||
accessible as the :attr:`pygame.event.Event.type` property. An event type's
|
||||
specific attributes can be accessed directly as an attribute on the event
|
||||
object.
|
||||
|
||||
Users can create their own new events (or emulate system events) by
|
||||
instantiating :func:`pygame.event.Event()` themselves, usually paired
|
||||
with :func:`pygame.event.post()`.
|
||||
|
||||
Events support equality and inequality comparisons. Two events are equal if
|
||||
they are the same type and have identical attribute values.
|
||||
|
||||
.. rubric:: Custom events and debugging
|
||||
|
||||
The event type identifier is in between the values of ``NOEVENT`` and
|
||||
``NUMEVENTS``. User defined events should have a value in the inclusive range
|
||||
of ``USEREVENT`` to ``NUMEVENTS - 1``. User defined events should reserve
|
||||
a custom event number with :func:`pygame.event.custom_type()`.
|
||||
|
||||
While debugging and experimenting, you can print an event object for a quick
|
||||
display of its type and members.
|
||||
|
||||
.. rubric:: Event types and attributes
|
||||
|
||||
Events that come from the system will have a guaranteed set of member
|
||||
attributes based on the type. The following are lists of event types with their
|
||||
specific attributes and notes.
|
||||
|
||||
You can also find a list of constants for keyboard keys
|
||||
:ref:`here <key-constants-label>`.
|
||||
|
||||
::
|
||||
|
||||
Event type Attributes/Notes
|
||||
|
||||
QUIT
|
||||
USEREVENT (Starting type of the user defined
|
||||
event types)
|
||||
|
||||
KEYDOWN key, mod, unicode, scancode, window(1)
|
||||
KEYUP key, mod, unicode, scancode, window(1)
|
||||
|
||||
MOUSEMOTION pos, rel, buttons, touch(2), window(1)
|
||||
MOUSEBUTTONUP pos, button, touch(2), clicks(3), window(1)
|
||||
MOUSEBUTTONDOWN pos, button, touch(2), clicks(3), window(1)
|
||||
MOUSEWHEEL which, flipped, x, y, touch(2), precise_x,
|
||||
precise_y, window(1), pos(5)
|
||||
|
||||
JOYAXISMOTION instance_id, axis, value (deprecated: joy)
|
||||
JOYBALLMOTION instance_id, ball, rel (deprecated: joy)
|
||||
JOYHATMOTION instance_id, hat, value (deprecated: joy)
|
||||
JOYBUTTONUP instance_id, button (deprecated: joy)
|
||||
JOYBUTTONDOWN instance_id, button (deprecated: joy)
|
||||
CONTROLLERDEVICEADDED device_index
|
||||
JOYDEVICEADDED device_index
|
||||
CONTROLLERDEVICEREMOVED instance_id
|
||||
JOYDEVICEREMOVED instance_id
|
||||
CONTROLLERDEVICEREMAPPED instance_id
|
||||
|
||||
(Use the window event API instead of legacy events)
|
||||
ACTIVEEVENT gain, state (Legacy event)
|
||||
VIDEORESIZE size, w, h (Legacy event)
|
||||
VIDEOEXPOSE (Legacy event)
|
||||
|
||||
AUDIODEVICEADDED which, iscapture
|
||||
AUDIODEVICEREMOVED which, iscapture
|
||||
|
||||
FINGERMOTION touch_id, finger_id, x, y, dx, dy, window(1)
|
||||
FINGERDOWN touch_id, finger_id, x, y, dx, dy, window(1)
|
||||
FINGERUP touch_id, finger_id, x, y, dx, dy, window(1)
|
||||
MULTIGESTURE touch_id, x, y, pinched, rotated, num_fingers
|
||||
|
||||
TEXTEDITING(4) text, start(4), length(4), window(1)
|
||||
TEXTINPUT(4) text, window(1)
|
||||
|
||||
DROPFILE window(1), file (Path of the file dropped
|
||||
on the window)
|
||||
DROPBEGIN window(1)
|
||||
DROPCOMPLETE window(1)
|
||||
DROPTEXT window(1)
|
||||
|
||||
MIDIIN (Reserved for pygame.midi use)
|
||||
MIDIOUT (Reserved for pygame.midi use)
|
||||
|
||||
KEYMAPCHANGED (Keymap change due to language/keyboard
|
||||
layout change)
|
||||
CLIPBOARDUPDATE (Partially experimental)
|
||||
LOCALECHANGED
|
||||
|
||||
RENDER_TARGETS_RESET
|
||||
RENDER_DEVICE_RESET
|
||||
|
||||
|
|
||||
|
||||
(``1``): if a :class:`pygame.Window` instance exists for the window that the event
|
||||
occurred in, the ``window`` attribute of these events will be that instance,
|
||||
otherwise it will be ``None``.
|
||||
|
||||
(``2``): The ``touch`` attribute of ``MOUSE`` events indicates whether or not the
|
||||
events were generated by a touch input device, and not a real mouse. You might
|
||||
want to ignore such events, if your application already handles ``FINGERMOTION``,
|
||||
``FINGERDOWN`` and ``FINGERUP`` events.
|
||||
|
||||
(``3``): The ``clicks`` attribute of the ``MOUSEBUTTONDOWN`` and ``MOUSEBUTTONUP``
|
||||
events indicate the number of clicks occurring in rapid succession, e.g. ``1``
|
||||
for single-click, ``2`` for double-click, etc. Note that double, triple, or
|
||||
more clicks will still fire mouse events for each individual click, with a
|
||||
progressively increasing ``clicks`` attribute.
|
||||
|
||||
(``4``): The ``start`` attribute of the ``TEXTEDITING`` event is the cursor position,
|
||||
in UTF-8 characters, where the new typing will be inserted into the editing text,
|
||||
while the ``length`` attribute is the number of UTF-8 characters that will be
|
||||
replaced by the new typing.
|
||||
|
||||
These ``TEXT*`` events are useful to implement inputs/languages that require composition,
|
||||
provided by the system's IME (Input Method Editor). The ``TEXTINPUT`` event is only
|
||||
fired when the text is confirmed.
|
||||
|
||||
(``5``): Position information was added to ``MOUSEWHEEL`` events in SDL 2.26.0. If
|
||||
pygame was built on a version lower than that, the ``pos`` attribute is ``None``.
|
||||
|
||||
|
|
||||
|
||||
Here is a list of the new window events.
|
||||
|
||||
All window events have a ``window`` attribute corresponding to the
|
||||
:class:`pygame.Window` that generated them.
|
||||
|
||||
::
|
||||
|
||||
Event type Short description and additional attributes
|
||||
|
||||
WINDOWSHOWN Window became shown
|
||||
WINDOWHIDDEN Window became hidden
|
||||
WINDOWEXPOSED Window got updated by some external event
|
||||
WINDOWMOVED Window got moved (x, y attributes)
|
||||
WINDOWSIZECHANGED Window size has changed (x, y attributes)
|
||||
WINDOWRESIZED Window got resized by the user/window manager
|
||||
(x, y attributes)
|
||||
WINDOWMINIMIZED Window was minimized
|
||||
WINDOWMAXIMIZED Window was maximized
|
||||
WINDOWRESTORED Window was restored
|
||||
WINDOWENTER Mouse entered the window
|
||||
WINDOWLEAVE Mouse left the window
|
||||
WINDOWFOCUSGAINED Window gained focus
|
||||
WINDOWFOCUSLOST Window lost focus
|
||||
WINDOWCLOSE Window was closed
|
||||
WINDOWTAKEFOCUS Window was offered focus
|
||||
WINDOWHITTEST Window has a special hit test
|
||||
WINDOWICCPROFCHANGED Window ICC profile changed
|
||||
(SDL backend >= 2.0.18)
|
||||
WINDOWDISPLAYCHANGED Window moved on a new display (display_index
|
||||
attribute. SDL backend >= 2.0.18)
|
||||
|
||||
|
|
||||
|
||||
On Android, the following events can be generated:
|
||||
|
||||
::
|
||||
|
||||
Event type Short description
|
||||
|
||||
APP_TERMINATING OS is terminating the application
|
||||
APP_LOWMEMORY OS is low on memory (try to free memory)
|
||||
APP_WILLENTERBACKGROUND Application is entering background
|
||||
APP_DIDENTERBACKGROUND Application entered background
|
||||
APP_WILLENTERFOREGROUND Application is entering foreground
|
||||
APP_DIDENTERFOREGROUND Application entered foreground
|
||||
|
||||
|
|
||||
|
||||
.. versionchangedold:: 2.0.0 The ``joy`` attribute was deprecated, ``instance_id`` was added.
|
||||
|
||||
.. versionaddedold:: 2.0.1 Window events and the ``unicode`` attribute for ``KEYUP`` events.
|
||||
|
||||
.. versionaddedold:: 2.0.2 The ``touch`` attribute was added to all the ``MOUSE`` events.
|
||||
|
||||
.. versionadded:: 2.1.3 Android events, ``precise_x`` and ``precise_y`` to ``MOUSEWHEEL`` events,
|
||||
``KEYMAPCHANGED``, ``CLIPBOARDUPDATE``, ``LOCALECHANGED``, ``WINDOWICCPROFCHANGED``,
|
||||
``WINDOWDISPLAYCHANGED``, ``RENDER_TARGETS_RESET``, and ``RENDER_DEVICE_RESET``.
|
||||
|
||||
.. versionadded:: 2.5.7 The ``clicks`` attribute was added to ``MOUSEBUTTONDOWN``
|
||||
and ``MOUSEBUTTONUP`` events.
|
||||
|
||||
.. versionadded:: 2.5.8 The ``pos`` attribute was added to ``MOUSEWHEEL`` events.
|
||||
|
||||
|
|
||||
|
||||
.. function:: pump
|
||||
|
||||
| :sl:`internally process pygame event handlers`
|
||||
| :sg:`pump() -> None`
|
||||
|
||||
For each frame of your game, you will need to make some sort of call to the
|
||||
event queue. This ensures your program can internally interact with the rest
|
||||
of the operating system. If you are not using other event functions in your
|
||||
game, you should call ``pygame.event.pump()`` to allow pygame to handle
|
||||
internal actions.
|
||||
|
||||
This function is not necessary if your program is consistently processing
|
||||
events on the queue through the other :mod:`pygame.event` functions.
|
||||
|
||||
There are important things that must be dealt with internally in the event
|
||||
queue. The main window may need to be repainted or respond to the system. If
|
||||
you fail to make a call to the event queue for too long, the system may
|
||||
decide your program has locked up.
|
||||
|
||||
.. caution::
|
||||
This function should only be called in the thread that initialized :mod:`pygame.display`.
|
||||
|
||||
.. ## pygame.event.pump ##
|
||||
|
||||
.. function:: get
|
||||
|
||||
| :sl:`get events from the queue`
|
||||
| :sg:`get(eventtype=None) -> Eventlist`
|
||||
| :sg:`get(eventtype=None, pump=True) -> Eventlist`
|
||||
| :sg:`get(eventtype=None, pump=True, exclude=None) -> Eventlist`
|
||||
|
||||
This will get all the messages and remove them from the queue. If a type or
|
||||
sequence of types is given only those messages will be removed from the
|
||||
queue and returned.
|
||||
|
||||
If a type or sequence of types is passed in the ``exclude`` argument
|
||||
instead, then all only *other* messages will be removed from the queue. If
|
||||
an ``exclude`` parameter is passed, the ``eventtype`` parameter *must* be
|
||||
None.
|
||||
|
||||
If you are only taking specific events from the queue, be aware that the
|
||||
queue could eventually fill up with the events you are not interested.
|
||||
|
||||
If ``pump`` is ``True`` (the default), then :func:`pygame.event.pump()` will be called.
|
||||
|
||||
.. versionchangedold:: 1.9.5 Added ``pump`` argument
|
||||
.. versionchangedold:: 2.0.2 Added ``exclude`` argument
|
||||
|
||||
.. ## pygame.event.get ##
|
||||
|
||||
.. function:: poll
|
||||
|
||||
| :sl:`get a single event from the queue`
|
||||
| :sg:`poll() -> Event instance`
|
||||
|
||||
Returns a single event from the queue. If the event queue is empty an event
|
||||
of type ``pygame.NOEVENT`` will be returned immediately. The returned event
|
||||
is removed from the queue.
|
||||
|
||||
.. caution::
|
||||
This function should only be called in the thread that initialized :mod:`pygame.display`.
|
||||
|
||||
.. ## pygame.event.poll ##
|
||||
|
||||
.. function:: wait
|
||||
|
||||
| :sl:`wait for a single event from the queue`
|
||||
| :sg:`wait() -> Event instance`
|
||||
| :sg:`wait(timeout) -> Event instance`
|
||||
|
||||
Returns a single event from the queue. If the queue is empty this function
|
||||
will wait until one is created. From pygame 2.0.0, if a ``timeout`` argument
|
||||
is given, the function will return an event of type ``pygame.NOEVENT``
|
||||
if no events enter the queue in ``timeout`` milliseconds. The event is removed
|
||||
from the queue once it has been returned. While the program is waiting it will
|
||||
sleep in an idle state. This is important for programs that want to share the
|
||||
system with other applications.
|
||||
|
||||
.. versionchangedold:: 2.0.0.dev13 Added ``timeout`` argument
|
||||
|
||||
.. caution::
|
||||
This function should only be called in the thread that initialized :mod:`pygame.display`.
|
||||
|
||||
.. ## pygame.event.wait ##
|
||||
|
||||
.. function:: peek
|
||||
|
||||
| :sl:`test if event types are waiting on the queue`
|
||||
| :sg:`peek(eventtype=None) -> bool`
|
||||
| :sg:`peek(eventtype=None, pump=True) -> bool`
|
||||
|
||||
Returns ``True`` if there are any events of the given type waiting on the
|
||||
queue. If a sequence of event types is passed, this will return ``True`` if
|
||||
any of those events are on the queue.
|
||||
|
||||
When ``eventtype`` is not passed or ``None``, this function will return ``True`` if
|
||||
there's any event on the queue, and return ``False`` if the queue is empty.
|
||||
|
||||
If ``pump`` is ``True`` (the default), then :func:`pygame.event.pump()` will be called.
|
||||
|
||||
.. versionchangedold:: 1.9.5 Added ``pump`` argument
|
||||
|
||||
.. versionchanged:: 2.5.3 no longer mistakenly returns an event when ``eventtype`` is None or not passed.
|
||||
|
||||
.. ## pygame.event.peek ##
|
||||
|
||||
.. function:: clear
|
||||
|
||||
| :sl:`remove all events from the queue`
|
||||
| :sg:`clear(eventtype=None) -> None`
|
||||
| :sg:`clear(eventtype=None, pump=True) -> None`
|
||||
|
||||
Removes all events from the queue. If ``eventtype`` is given, removes the given event
|
||||
or sequence of events. This has the same effect as :func:`pygame.event.get()` except ``None``
|
||||
is returned. It can be slightly more efficient when clearing a full event queue.
|
||||
|
||||
If ``pump`` is ``True`` (the default), then :func:`pygame.event.pump()` will be called.
|
||||
|
||||
.. versionchangedold:: 1.9.5 Added ``pump`` argument
|
||||
|
||||
.. ## pygame.event.clear ##
|
||||
|
||||
.. function:: event_name
|
||||
|
||||
| :sl:`get the string name from an event id`
|
||||
| :sg:`event_name(type, /) -> string`
|
||||
|
||||
Returns a string representing the name (in CapWords style) of the given
|
||||
event type.
|
||||
|
||||
"UserEvent" is returned for all values in the user event id range.
|
||||
"Unknown" is returned when the event type does not exist.
|
||||
|
||||
.. ## pygame.event.event_name ##
|
||||
|
||||
.. function:: set_blocked
|
||||
|
||||
| :sl:`control which events are blocked on the queue`
|
||||
| :sg:`set_blocked(type, /) -> None`
|
||||
| :sg:`set_blocked(typelist, /) -> None`
|
||||
| :sg:`set_blocked(None) -> None`
|
||||
|
||||
The given event types are not allowed to appear on the event queue. By
|
||||
default all events can be placed on the queue. It is safe to disable an
|
||||
event type multiple times.
|
||||
|
||||
If ``None`` is passed as the argument, ALL of the event types are blocked
|
||||
from being placed on the queue.
|
||||
|
||||
.. ## pygame.event.set_blocked ##
|
||||
|
||||
.. function:: set_allowed
|
||||
|
||||
| :sl:`control which events are allowed on the queue`
|
||||
| :sg:`set_allowed(type, /) -> None`
|
||||
| :sg:`set_allowed(typelist, /) -> None`
|
||||
| :sg:`set_allowed(None) -> None`
|
||||
|
||||
The given event types are allowed to appear on the event queue. By default,
|
||||
all event types can be placed on the queue. It is safe to enable an event
|
||||
type multiple times.
|
||||
|
||||
If ``None`` is passed as the argument, ALL of the event types are allowed
|
||||
to be placed on the queue.
|
||||
|
||||
.. ## pygame.event.set_allowed ##
|
||||
|
||||
.. function:: get_blocked
|
||||
|
||||
| :sl:`test if a type of event is blocked from the queue`
|
||||
| :sg:`get_blocked(type, /) -> bool`
|
||||
| :sg:`get_blocked(typelist, /) -> bool`
|
||||
|
||||
Returns ``True`` if the given event type is blocked from the queue. If a
|
||||
sequence of event types is passed, this will return ``True`` if any of those
|
||||
event types are blocked.
|
||||
|
||||
.. ## pygame.event.get_blocked ##
|
||||
|
||||
.. function:: set_grab
|
||||
|
||||
| :sl:`control the sharing of input devices with other applications`
|
||||
| :sg:`set_grab(bool, /) -> None`
|
||||
|
||||
When your program runs in a windowed environment, it will share the mouse
|
||||
and keyboard devices with other applications that have focus. If your
|
||||
program sets the event grab to ``True``, it will lock all input into your
|
||||
program.
|
||||
|
||||
It is best to not always grab the input, since it prevents the user from
|
||||
doing other things on their system.
|
||||
|
||||
.. ## pygame.event.set_grab ##
|
||||
|
||||
.. function:: get_grab
|
||||
|
||||
| :sl:`test if the program is sharing input devices`
|
||||
| :sg:`get_grab() -> bool`
|
||||
|
||||
Returns ``True`` when the input events are grabbed for this application.
|
||||
|
||||
.. ## pygame.event.get_grab ##
|
||||
|
||||
.. function:: post
|
||||
|
||||
| :sl:`place a new event on the queue`
|
||||
| :sg:`post(event, /) -> bool`
|
||||
|
||||
Places the given event at the end of the event queue.
|
||||
|
||||
This is usually used for placing custom events on the event queue.
|
||||
Any type of event can be posted, and the events posted can have any attributes.
|
||||
|
||||
When this event is received on the event queue, it will be a shallow copy of
|
||||
the event object posted by this function; the dict attribute of both events
|
||||
will be a reference to the same dict object in memory. Modifications on one
|
||||
dict can affect another, use deepcopy operations on the dict object if you
|
||||
don't want this behaviour.
|
||||
|
||||
This returns a boolean on whether the event was posted or not. Blocked events
|
||||
cannot be posted, and this function returns ``False`` if you try to post them.
|
||||
|
||||
.. versionchangedold:: 2.0.1 returns a boolean, previously returned ``None``
|
||||
|
||||
.. ## pygame.event.post ##
|
||||
|
||||
.. function:: custom_type
|
||||
|
||||
| :sl:`make custom user event type`
|
||||
| :sg:`custom_type() -> int`
|
||||
|
||||
Reserves an event slot for use in a custom event ``userevent`` and returns the integer that the event slot is reserved to.
|
||||
|
||||
If too many events are made a :exc:`pygame.error` is raised.
|
||||
|
||||
.. versionaddedold:: 2.0.0.dev3
|
||||
|
||||
.. ## pygame.event.custom_type ##
|
||||
|
||||
.. class:: Event
|
||||
|
||||
| :sl:`pygame object for representing events`
|
||||
| :sg:`Event(type, dict) -> Event`
|
||||
| :sg:`Event(type, \**attributes) -> Event`
|
||||
|
||||
A pygame object used for representing an event. ``Event`` instances
|
||||
support attribute assignment and deletion.
|
||||
|
||||
When creating the object, the attributes may come from a dictionary
|
||||
argument with string keys or from keyword arguments.
|
||||
|
||||
.. versionchanged:: 2.1.4 This class is also available through the ``pygame.Event``
|
||||
alias.
|
||||
|
||||
.. note::
|
||||
From version 2.1.3 ``EventType`` is an alias for ``Event``. Beforehand,
|
||||
``Event`` was a function that returned ``EventType`` instances. Use of
|
||||
``Event`` is preferred over ``EventType`` wherever it is possible, as
|
||||
the latter could be deprecated in a future version.
|
||||
|
||||
.. attribute:: type
|
||||
|
||||
| :sl:`event type identifier.`
|
||||
| :sg:`type -> int`
|
||||
|
||||
Read-only. The event type identifier. For user created event
|
||||
objects, this is the ``type`` argument passed to
|
||||
:class:`pygame.event.Event()`.
|
||||
|
||||
For example, some predefined event identifiers are ``QUIT`` and
|
||||
``MOUSEMOTION``.
|
||||
|
||||
.. ## pygame.event.Event.type ##
|
||||
|
||||
.. attribute:: __dict__
|
||||
|
||||
| :sl:`event attribute dictionary`
|
||||
| :sg:`__dict__ -> dict`
|
||||
|
||||
Read-only. The event type specific attributes of an event. The
|
||||
``dict`` attribute is a synonym for backward compatibility.
|
||||
|
||||
For example, the attributes of a ``KEYDOWN`` event would be ``unicode``,
|
||||
``key``, and ``mod``
|
||||
|
||||
.. ## pygame.event.Event.__dict__ ##
|
||||
|
||||
.. versionaddedold:: 1.9.2 Mutable attributes.
|
||||
|
||||
.. ## pygame.event.Event ##
|
||||
|
||||
.. ## pygame.event ##
|
||||
@@ -0,0 +1,451 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.examples`
|
||||
======================
|
||||
|
||||
.. module:: pygame.examples
|
||||
:synopsis: module of example programs
|
||||
|
||||
| :sl:`module of example programs`
|
||||
|
||||
These examples should help get you started with pygame. Here is a brief rundown
|
||||
of what you get. The source code for these examples is in the public domain.
|
||||
Feel free to use for your own projects.
|
||||
|
||||
There are several ways to run the examples. First they can be run as
|
||||
stand-alone programs. Second they can be imported and their ``main()`` methods
|
||||
called (see below). Finally, the easiest way is to use the python -m option:
|
||||
|
||||
::
|
||||
|
||||
python -m pygame.examples.<example name> <example arguments>
|
||||
|
||||
eg:
|
||||
|
||||
::
|
||||
|
||||
python -m pygame.examples.scaletest someimage.png
|
||||
|
||||
Resources such as images and sounds for the examples are found in the
|
||||
pygame/examples/data subdirectory.
|
||||
|
||||
You can find where the example files are installed by using the following
|
||||
commands inside the python interpreter.
|
||||
|
||||
::
|
||||
|
||||
>>> import pygame.examples.scaletest
|
||||
>>> pygame.examples.scaletest.__file__
|
||||
'/usr/lib/python2.6/site-packages/pygame/examples/scaletest.py'
|
||||
|
||||
On each OS and version of Python the location will be slightly different.
|
||||
For example on Windows it might be in 'C:/Python26/Lib/site-packages/pygame/examples/'
|
||||
On Mac OS X it might be in '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pygame/examples/'
|
||||
|
||||
|
||||
You can also run the examples in the python interpreter by calling each modules main() function.
|
||||
|
||||
::
|
||||
|
||||
>>> import pygame.examples.scaletest
|
||||
>>> pygame.examples.scaletest.main()
|
||||
|
||||
|
||||
We're always on the lookout for more examples and/or example requests. Code
|
||||
like this is probably the best way to start getting involved with python
|
||||
gaming.
|
||||
|
||||
examples as a package is new to pygame 1.9.0. But most of the examples came with
|
||||
pygame much earlier.
|
||||
|
||||
.. function:: aliens.main
|
||||
|
||||
| :sl:`play the full aliens example`
|
||||
| :sg:`aliens.main() -> None`
|
||||
|
||||
This started off as a port of the ``SDL`` demonstration, Aliens. Now it has
|
||||
evolved into something sort of resembling fun. This demonstrates a lot of
|
||||
different uses of sprites and optimized blitting. Also transparency,
|
||||
colorkeys, fonts, sound, music, joystick, and more. (PS, my high score is
|
||||
117! goodluck)
|
||||
|
||||
.. ## pygame.examples.aliens.main ##
|
||||
|
||||
.. function:: stars.main
|
||||
|
||||
| :sl:`run a simple starfield example`
|
||||
| :sg:`stars.main() -> None`
|
||||
|
||||
A simple starfield example. You can change the center of perspective by
|
||||
leftclicking the mouse on the screen.
|
||||
|
||||
.. ## pygame.examples.stars.main ##
|
||||
|
||||
.. function:: chimp.main
|
||||
|
||||
| :sl:`hit the moving chimp`
|
||||
| :sg:`chimp.main() -> None`
|
||||
|
||||
This simple example is derived from the line-by-line tutorial that comes
|
||||
with pygame. It is based on a 'popular' web banner. Note there are comments
|
||||
here, but for the full explanation, follow along in the tutorial.
|
||||
|
||||
.. ## pygame.examples.chimp.main ##
|
||||
|
||||
.. function:: moveit.main
|
||||
|
||||
| :sl:`display animated objects on the screen`
|
||||
| :sg:`moveit.main() -> None`
|
||||
|
||||
This is the full and final example from the Pygame Tutorial, "How Do I Make
|
||||
It Move". It creates 10 objects and animates them on the screen.
|
||||
|
||||
Note it's a bit scant on error checking, but it's easy to read. :]
|
||||
Fortunately, this is python, and we needn't wrestle with a pile of error
|
||||
codes.
|
||||
|
||||
.. ## pygame.examples.moveit.main ##
|
||||
|
||||
.. function:: fonty.main
|
||||
|
||||
| :sl:`run a font rendering example`
|
||||
| :sg:`fonty.main() -> None`
|
||||
|
||||
Super quick, super simple application demonstrating the different ways to
|
||||
render fonts with the font module
|
||||
|
||||
.. ## pygame.examples.fonty.main ##
|
||||
|
||||
.. function:: freetype_misc.main
|
||||
|
||||
| :sl:`run a FreeType rendering example`
|
||||
| :sg:`freetype_misc.main() -> None`
|
||||
|
||||
A showcase of rendering features the :class:`pygame.freetype.Font`
|
||||
class provides in addition to those available with :class:`pygame.font.Font`.
|
||||
It is a demonstration of direct to surface rendering, with vertical text
|
||||
and rotated text, opaque text and semi transparent text, horizontally
|
||||
stretched text and vertically stretched text.
|
||||
|
||||
.. ## pygame.examples.fonty.main ##
|
||||
|
||||
.. function:: vgrade.main
|
||||
|
||||
| :sl:`display a vertical gradient`
|
||||
| :sg:`vgrade.main() -> None`
|
||||
|
||||
Demonstrates creating a vertical gradient with pixelcopy and NumPy python.
|
||||
The app will create a new gradient every half second and report the time
|
||||
needed to create and display the image. If you're not prepared to start
|
||||
working with the NumPy arrays, don't worry about the source for this one :]
|
||||
|
||||
.. ## pygame.examples.vgrade.main ##
|
||||
|
||||
.. function:: eventlist.main
|
||||
|
||||
| :sl:`display pygame events`
|
||||
| :sg:`eventlist.main() -> None`
|
||||
|
||||
Eventlist is a sloppy style of pygame, but is a handy tool for learning
|
||||
about pygame events and input. At the top of the screen are the state of
|
||||
several device values, and a scrolling list of events are displayed on the
|
||||
bottom.
|
||||
|
||||
This is not quality 'ui' code at all, but you can see how to implement very
|
||||
non-interactive status displays, or even a crude text output control.
|
||||
|
||||
.. ## pygame.examples.eventlist.main ##
|
||||
|
||||
.. function:: arraydemo.main
|
||||
|
||||
| :sl:`show various surfarray effects`
|
||||
| :sg:`arraydemo.main(arraytype=None) -> None`
|
||||
|
||||
Another example filled with various surfarray effects. It requires the
|
||||
surfarray and image modules to be installed. This little demo can also make
|
||||
a good starting point for any of your own tests with surfarray
|
||||
|
||||
The ``arraytype`` parameter is deprecated; passing any value besides 'numpy'
|
||||
will raise ValueError.
|
||||
|
||||
.. ## pygame.examples.arraydemo.main ##
|
||||
|
||||
.. function:: sound.main
|
||||
|
||||
| :sl:`load and play a sound`
|
||||
| :sg:`sound.main(file_path=None) -> None`
|
||||
|
||||
Extremely basic testing of the mixer module. Load a sound and play it. All
|
||||
from the command shell, no graphics.
|
||||
|
||||
If provided, use the audio file 'file_path', otherwise use a default file.
|
||||
|
||||
``sound.py`` optional command line argument: an audio file
|
||||
|
||||
.. ## pygame.examples.sound.main ##
|
||||
|
||||
.. function:: sound_array_demos.main
|
||||
|
||||
| :sl:`play various sndarray effects`
|
||||
| :sg:`sound_array_demos.main(arraytype=None) -> None`
|
||||
|
||||
|
||||
Uses sndarray and NumPy to create offset faded copies of the
|
||||
original sound. Currently it just uses hardcoded values for the number of
|
||||
echoes and the delay. Easy for you to recreate as needed.
|
||||
|
||||
The ``arraytype`` parameter is deprecated; passing any value besides 'numpy'
|
||||
will raise ValueError.
|
||||
|
||||
.. ## pygame.examples.sound_array_demos.main ##
|
||||
|
||||
.. function:: liquid.main
|
||||
|
||||
| :sl:`display an animated liquid effect`
|
||||
| :sg:`liquid.main() -> None`
|
||||
|
||||
This example was created in a quick comparison with the BlitzBasic gaming
|
||||
language. Nonetheless, it demonstrates a quick 8-bit setup (with colormap).
|
||||
|
||||
.. ## pygame.examples.liquid.main ##
|
||||
|
||||
.. function:: glcube.main
|
||||
|
||||
| :sl:`display an animated 3D cube using OpenGL`
|
||||
| :sg:`glcube.main() -> None`
|
||||
|
||||
Using PyOpenGL and pygame, this creates a spinning 3D multicolored cube.
|
||||
|
||||
.. ## pygame.examples.glcube.main ##
|
||||
|
||||
.. function:: scrap_clipboard.main
|
||||
|
||||
| :sl:`access the clipboard`
|
||||
| :sg:`scrap_clipboard.main() -> None`
|
||||
|
||||
A simple demonstration example for the clipboard support.
|
||||
|
||||
.. ## pygame.examples.scrap_clipboard.main ##
|
||||
|
||||
.. function:: mask.main
|
||||
|
||||
| :sl:`display multiple images bounce off each other using collision detection`
|
||||
| :sg:`mask.main(*args) -> None`
|
||||
|
||||
Positional arguments:
|
||||
|
||||
::
|
||||
|
||||
one or more image file names.
|
||||
|
||||
This ``pygame.masks`` demo will display multiple moving sprites bouncing off
|
||||
each other. More than one sprite image can be provided.
|
||||
|
||||
If run as a program then ``mask.py`` takes one or more image files as
|
||||
command line arguments.
|
||||
|
||||
.. ## pygame.examples.mask.main ##
|
||||
|
||||
.. function:: testsprite.main
|
||||
|
||||
| :sl:`show lots of sprites moving around`
|
||||
| :sg:`testsprite.main(update_rects = True, use_static = False, use_FastRenderGroup = False, screen_dims = [640, 480], use_alpha = False, flags = 0) -> None`
|
||||
|
||||
Optional keyword arguments:
|
||||
|
||||
::
|
||||
|
||||
update_rects - use the RenderUpdate sprite group class
|
||||
use_static - include non-moving images
|
||||
use_FastRenderGroup - Use the FastRenderGroup sprite group
|
||||
screen_dims - pygame window dimensions
|
||||
use_alpha - use alpha blending
|
||||
flags - additional display mode flags
|
||||
|
||||
Like the ``testsprite.c`` that comes with SDL, this pygame version shows
|
||||
lots of sprites moving around.
|
||||
|
||||
If run as a stand-alone program then no command line arguments are taken.
|
||||
|
||||
.. ## pygame.examples.testsprite.main ##
|
||||
|
||||
.. function:: headless_no_windows_needed.main
|
||||
|
||||
| :sl:`write an image file that is smoothscaled copy of an input file`
|
||||
| :sg:`headless_no_windows_needed.main(fin, fout, w, h) -> None`
|
||||
|
||||
arguments:
|
||||
|
||||
::
|
||||
|
||||
fin - name of an input image file
|
||||
fout - name of the output file to create/overwrite
|
||||
w, h - size of the rescaled image, as integer width and height
|
||||
|
||||
How to use pygame with no windowing system, like on headless servers.
|
||||
|
||||
Thumbnail generation with scaling is an example of what you can do with
|
||||
pygame.
|
||||
|
||||
``NOTE``: the pygame scale function uses SIMD acceleration if available,
|
||||
and can be run in multiple threads.
|
||||
|
||||
If ``headless_no_windows_needed.py`` is run as a program it takes the
|
||||
following command line arguments:
|
||||
|
||||
::
|
||||
|
||||
-scale inputimage outputimage new_width new_height
|
||||
eg. -scale in.png outpng 50 50
|
||||
|
||||
.. ## pygame.examples.headless_no_windows_needed.main ##
|
||||
|
||||
.. function:: joystick.main
|
||||
|
||||
| :sl:`demonstrate joystick functionality`
|
||||
| :sg:`joystick.main() -> None`
|
||||
|
||||
A demo showing full joystick support.
|
||||
|
||||
.. versionaddedold:: 2.0.2
|
||||
|
||||
.. ## pygame.examples.joystick.main ##
|
||||
|
||||
.. function:: blend_fill.main
|
||||
|
||||
| :sl:`demonstrate the various surface.fill method blend options`
|
||||
| :sg:`blend_fill.main() -> None`
|
||||
|
||||
A interactive demo that lets one choose which BLEND_xxx option to apply to a
|
||||
surface.
|
||||
|
||||
.. ## pygame.examples.blend_fill.main ##
|
||||
|
||||
.. function:: blit_blends.main
|
||||
|
||||
| :sl:`uses alternative additive fill to that of surface.fill`
|
||||
| :sg:`blit_blends.main() -> None`
|
||||
|
||||
Fake additive blending. Using NumPy. it doesn't clamp. Press r,g,b Somewhat
|
||||
like blend_fill.
|
||||
|
||||
.. ## pygame.examples.blit_blends.main ##
|
||||
|
||||
.. function:: cursors.main
|
||||
|
||||
| :sl:`display two different custom cursors`
|
||||
| :sg:`cursors.main() -> None`
|
||||
|
||||
Display an arrow or circle with crossbar cursor.
|
||||
|
||||
.. ## pygame.examples.cursors.main ##
|
||||
|
||||
.. function:: pixelarray.main
|
||||
|
||||
| :sl:`display various pixelarray generated effects`
|
||||
| :sg:`pixelarray.main() -> None`
|
||||
|
||||
Display various pixelarray generated effects.
|
||||
|
||||
.. ## pygame.examples.pixelarray.main ##
|
||||
|
||||
.. function:: scaletest.main
|
||||
|
||||
| :sl:`interactively scale an image using smoothscale`
|
||||
| :sg:`scaletest.main(imagefile, convert_alpha=False, run_speed_test=True) -> None`
|
||||
|
||||
arguments:
|
||||
|
||||
::
|
||||
|
||||
imagefile - file name of source image (required)
|
||||
convert_alpha - use convert_alpha() on the surf (default False)
|
||||
run_speed_test - (default False)
|
||||
|
||||
A smoothscale example that resized an image on the screen. Vertical and
|
||||
horizontal arrow keys are used to change the width and height of the
|
||||
displayed image. If the convert_alpha option is True then the source image
|
||||
is forced to have source alpha, whether or not the original images does. If
|
||||
run_speed_test is True then a background timing test is performed instead of
|
||||
the interactive scaler.
|
||||
|
||||
If ``scaletest.py`` is run as a program then the command line options are:
|
||||
|
||||
::
|
||||
|
||||
ImageFile [-t] [-convert_alpha]
|
||||
[-t] = Run Speed Test
|
||||
[-convert_alpha] = Use convert_alpha() on the surf.
|
||||
|
||||
.. ## pygame.examples.scaletest.main ##
|
||||
|
||||
.. function:: midi.main
|
||||
|
||||
| :sl:`run a midi example`
|
||||
| :sg:`midi.main(mode='output', device_id=None) -> None`
|
||||
|
||||
Arguments:
|
||||
|
||||
::
|
||||
|
||||
mode - if 'output' run a midi keyboard output example
|
||||
'input' run a midi event logger input example
|
||||
'list' list available midi devices
|
||||
(default 'output')
|
||||
device_id - midi device number; if None then use the default midi input or
|
||||
output device for the system
|
||||
|
||||
The output example shows how to translate mouse clicks or computer keyboard
|
||||
events into midi notes. It implements a rudimentary button widget and state
|
||||
machine.
|
||||
|
||||
The input example shows how to translate midi input to pygame events.
|
||||
|
||||
With the use of a virtual midi patch cord the output and input examples can
|
||||
be run as separate processes and connected so the keyboard output is
|
||||
displayed on a console.
|
||||
|
||||
new to pygame 1.9.0
|
||||
|
||||
.. ## pygame.examples.midi.main ##
|
||||
|
||||
.. function:: scroll.main
|
||||
|
||||
| :sl:`run a Surface.scroll example that shows a magnified image`
|
||||
| :sg:`scroll.main(image_file=None) -> None`
|
||||
|
||||
This example shows a scrollable image that has a zoom factor of eight. It
|
||||
uses the :meth:`Surface.scroll() <pygame.Surface.scroll>`
|
||||
function to shift the image on the display surface.
|
||||
A clip rectangle protects a margin area. If called as a function,
|
||||
the example accepts an optional image file path. If run as a program it
|
||||
takes an optional file path command line argument. If no file is provided a
|
||||
default image file is used.
|
||||
|
||||
When running click on a black triangle to move one pixel in the direction
|
||||
the triangle points. Or use the arrow keys. Close the window or press
|
||||
``ESC`` to quit.
|
||||
|
||||
.. ## pygame.examples.scroll.main ##
|
||||
|
||||
.. function:: camera.main
|
||||
|
||||
| :sl:`display video captured live from an attached camera`
|
||||
| :sg:`camera.main() -> None`
|
||||
|
||||
A simple live video player, it uses the first available camera it finds on
|
||||
the system.
|
||||
|
||||
.. ## pygame.examples.camera.main ##
|
||||
|
||||
.. function:: playmus.main
|
||||
|
||||
| :sl:`play an audio file`
|
||||
| :sg:`playmus.main(file_path) -> None`
|
||||
|
||||
A simple music player with window and keyboard playback control. Playback can
|
||||
be paused and rewound to the beginning.
|
||||
|
||||
.. ## pygame.examples.playmus.main ##
|
||||
|
||||
.. ## pygame.examples ##
|
||||
@@ -0,0 +1,389 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.font`
|
||||
==================
|
||||
|
||||
.. module:: pygame.font
|
||||
:synopsis: pygame module for loading and rendering fonts
|
||||
|
||||
| :sl:`pygame module for loading and rendering fonts`
|
||||
|
||||
The font module allows for rendering TrueType fonts into Surface objects.
|
||||
This module is built on top of the SDL_ttf library, which comes with all
|
||||
normal pygame installations.
|
||||
|
||||
Most of the work done with fonts are done by using the actual Font objects.
|
||||
The module by itself only has routines to support the creation of Font objects
|
||||
with :func:`pygame.font.Font`.
|
||||
|
||||
You can load fonts from the system by using the :func:`pygame.font.SysFont`
|
||||
function. There are a few other functions to help look up the system fonts.
|
||||
|
||||
Pygame comes with a builtin default font, freesansbold. This can always be
|
||||
accessed by passing ``None`` as the font name.
|
||||
|
||||
Before pygame 2.0.3, pygame.font accepts any UCS-2 / UTF-16 character
|
||||
('\\u0001' to '\\uFFFF'). After 2.0.3, pygame.font built with SDL_ttf
|
||||
2.0.15 accepts any valid UCS-4 / UTF-32 character
|
||||
(like emojis, if the font has them) ('\\U00000001' to '\\U0010FFFF')).
|
||||
More about this in :func:`Font.render`.
|
||||
|
||||
Before pygame 2.0.3, this character space restriction can be avoided by
|
||||
using the :mod:`pygame.freetype` based ``pygame.ftfont`` to emulate the Font
|
||||
module. This can be used by defining the environment variable PYGAME_FREETYPE
|
||||
before the first import of :mod:`pygame`. Since the problem ``pygame.ftfont``
|
||||
solves no longer exists, it will likely be removed in the future.
|
||||
|
||||
.. function:: init
|
||||
|
||||
| :sl:`Initialize the font module.`
|
||||
| :sg:`init() -> None`
|
||||
|
||||
This method is called automatically by ``pygame.init()``. It initializes the
|
||||
font module. The module must be initialized before any other functions will
|
||||
work.
|
||||
|
||||
It is safe to call this function more than once.
|
||||
|
||||
.. ## pygame.font.init ##
|
||||
|
||||
.. function:: quit
|
||||
|
||||
| :sl:`Uninitialize the font module.`
|
||||
| :sg:`quit() -> None`
|
||||
|
||||
Manually uninitialize SDL_ttf's font system. This is called automatically by
|
||||
``pygame.quit()``.
|
||||
|
||||
It is safe to call this function even if font is currently not initialized.
|
||||
|
||||
Previously created font objects will be invalid after the font module is quit.
|
||||
|
||||
.. ## pygame.font.quit ##
|
||||
|
||||
.. function:: get_init
|
||||
|
||||
| :sl:`True if the font module is initialized.`
|
||||
| :sg:`get_init() -> bool`
|
||||
|
||||
Test if the font module is initialized or not.
|
||||
|
||||
.. ## pygame.font.get_init ##
|
||||
|
||||
.. autopgfunction:: get_default_font
|
||||
|
||||
.. autopgfunction:: get_sdl_ttf_version
|
||||
|
||||
.. autopgfunction:: get_fonts
|
||||
|
||||
.. autopgfunction:: match_font
|
||||
|
||||
.. function:: SysFont
|
||||
|
||||
| :sl:`Create a Font object from the system fonts.`
|
||||
| :sg:`SysFont(name, size, bold=False, italic=False) -> Font`
|
||||
|
||||
Return a new Font object that is loaded from the system fonts. The font will
|
||||
match the requested bold and italic flags. Pygame uses a small set of common
|
||||
font aliases. If the specific font you ask for is not available, a reasonable
|
||||
alternative may be used. If a suitable system font is not found this will
|
||||
fall back on loading the default pygame font.
|
||||
|
||||
The font name can also be an iterable of font names, a string of
|
||||
comma-separated font names, or a bytes of comma-separated font names, in
|
||||
which case the set of names will be searched in order.
|
||||
|
||||
.. versionaddedold:: 2.0.1 Accept an iterable of font names.
|
||||
|
||||
.. versionchanged:: 2.1.3 Checks through user fonts instead of just global fonts for Windows.
|
||||
|
||||
.. ## pygame.font.SysFont ##
|
||||
|
||||
.. class:: Font
|
||||
|
||||
| :sl:`Create a new Font object from a file.`
|
||||
| :sg:`Font(filename=None, size=20) -> Font`
|
||||
| :sg:`Font(filename, size) -> Font`
|
||||
| :sg:`Font(pathlib.Path, size) -> Font`
|
||||
| :sg:`Font(object, size) -> Font`
|
||||
|
||||
Load a new font from a given filename or a python file object. The size is
|
||||
the height of the font in pixels. If the filename is ``None`` the pygame
|
||||
default font will be loaded. If a font cannot be loaded from the arguments
|
||||
given an exception will be raised. Once the font is created the size cannot
|
||||
be changed.
|
||||
|
||||
Font objects are mainly used to render text into new Surface objects. The
|
||||
render can emulate bold or italic features, but it is better to load from a
|
||||
font with actual italic or bold glyphs.
|
||||
|
||||
.. versionchanged:: 2.1.4 If no arguments are given then the default font will be used and
|
||||
a font size of 20 is used.
|
||||
|
||||
.. versionchanged:: 2.1.4 This class is also available through the ``pygame.Font``
|
||||
alias.
|
||||
|
||||
.. attribute:: bold
|
||||
|
||||
| :sl:`Gets or sets whether the font should be rendered in (faked) bold.`
|
||||
| :sg:`bold -> bool`
|
||||
|
||||
Whether the font should be rendered in bold.
|
||||
|
||||
When set to True, this enables the bold rendering of text. This
|
||||
is a fake stretching of the font that doesn't look good on many
|
||||
font types. If possible load the font from a real bold font
|
||||
file. While bold, the font will have a different width than when
|
||||
normal. This can be mixed with the italic, underline and
|
||||
strikethrough modes.
|
||||
|
||||
.. versionaddedold:: 2.0.0
|
||||
|
||||
.. ## Font.bold ##
|
||||
|
||||
.. attribute:: name
|
||||
|
||||
| :sl:`Gets the font's name.`
|
||||
| :sg:`name -> str`
|
||||
|
||||
Read only. Returns the font's name.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
.. ## Font.name ##
|
||||
|
||||
.. attribute:: style_name
|
||||
|
||||
| :sl:`Gets the font's style_name.`
|
||||
| :sg:`style_name -> str`
|
||||
|
||||
Read only. Returns the font's style name. Style names are arbitrary, can be an empty string.
|
||||
Here are some examples:
|
||||
|
||||
'Black', 'Bold', 'Bold Italic', 'BoldOblique', 'Book', 'BookOblique', 'Condensed', 'Condensed Oblique',
|
||||
'ExtraLight', 'Italic', 'Light', 'LightOblique', 'Medium', 'MediumOblique', 'Oblique', 'Regular',
|
||||
'Semibold', 'Semilight', 'Slanted'
|
||||
|
||||
|
||||
.. versionadded:: 2.3.1
|
||||
|
||||
.. ## Font.style_name ##
|
||||
|
||||
.. attribute:: italic
|
||||
|
||||
| :sl:`Gets or sets whether the font should be rendered in (faked) italics.`
|
||||
| :sg:`italic -> bool`
|
||||
|
||||
Whether the font should be rendered in italic.
|
||||
|
||||
When set to True, this enables fake rendering of italic
|
||||
text. This is a fake skewing of the font that doesn't look good
|
||||
on many font types. If possible load the font from a real italic
|
||||
font file. While italic the font will have a different width
|
||||
than when normal. This can be mixed with the bold, underline and
|
||||
strikethrough modes.
|
||||
|
||||
.. versionaddedold:: 2.0.0
|
||||
|
||||
.. ## Font.italic ##
|
||||
|
||||
.. attribute:: underline
|
||||
|
||||
| :sl:`Gets or sets whether the font should be rendered with an underline.`
|
||||
| :sg:`underline -> bool`
|
||||
|
||||
Whether the font should be rendered in underline.
|
||||
|
||||
When set to True, all rendered fonts will include an
|
||||
underline. The underline is always one pixel thick, regardless
|
||||
of font size. This can be mixed with the bold, italic and
|
||||
strikethrough modes.
|
||||
|
||||
.. versionaddedold:: 2.0.0
|
||||
|
||||
.. ## Font.underline ##
|
||||
|
||||
.. attribute:: strikethrough
|
||||
|
||||
| :sl:`Gets or sets whether the font should be rendered with a strikethrough.`
|
||||
| :sg:`strikethrough -> bool`
|
||||
|
||||
Whether the font should be rendered with a strikethrough.
|
||||
|
||||
When set to True, all rendered fonts will include an
|
||||
strikethrough. The strikethrough is always one pixel thick,
|
||||
regardless of font size. This can be mixed with the bold,
|
||||
italic and underline modes.
|
||||
|
||||
.. versionadded:: 2.1.3
|
||||
|
||||
.. ## Font.strikethrough ##
|
||||
|
||||
.. attribute:: align
|
||||
|
||||
| :sl:`Gets or sets how rendered text is aligned when given a wrap length.`
|
||||
| :sg:`align -> int`
|
||||
|
||||
Can be set to `pygame.FONT_LEFT`, `pygame.FONT_RIGHT`, or
|
||||
`pygame.FONT_CENTER`. This controls the text alignment behavior for the
|
||||
font. Defaults to `pygame.FONT_LEFT`.
|
||||
|
||||
Requires pygame built with SDL_ttf 2.20.0, as all official pygame
|
||||
distributions are.
|
||||
|
||||
.. versionadded:: 2.1.4
|
||||
|
||||
.. ## Font.align ##
|
||||
|
||||
.. attribute:: point_size
|
||||
|
||||
| :sl:`Gets or sets the font's point size.`
|
||||
| :sg:`point_size -> int`
|
||||
|
||||
Returns the point size of the font. Will not be accurate upon initializing
|
||||
the font object when the font name is initialized as ``None``.
|
||||
|
||||
.. versionadded:: 2.3.1
|
||||
|
||||
.. ## Font.point_size ##
|
||||
|
||||
|
||||
.. attribute:: outline
|
||||
|
||||
| :sl:`Gets or sets the font's outline thickness (pixels).`
|
||||
| :sg:`outline -> int`
|
||||
|
||||
The outline value of the font.
|
||||
|
||||
When set to 0, the font will be drawn normally. When positive,
|
||||
the text will be drawn as a hollow outline. The outline grows in all
|
||||
directions a number of pixels equal to the value set. Negative values
|
||||
are not allowed.
|
||||
|
||||
This can be drawn underneath unoutlined text to create a text outline
|
||||
effect. For example: ::
|
||||
|
||||
def render_outlined(
|
||||
font: pygame.Font,
|
||||
text: str,
|
||||
text_color: pygame.typing.ColorLike,
|
||||
outline_color: pygame.typing.ColorLike,
|
||||
outline_width: int,
|
||||
) -> pygame.Surface:
|
||||
old_outline = font.outline
|
||||
if old_outline != 0:
|
||||
font.outline = 0
|
||||
base_text_surf = font.render(text, True, text_color)
|
||||
font.outline = outline_width
|
||||
outlined_text_surf = font.render(text, True, outline_color)
|
||||
|
||||
outlined_text_surf.blit(base_text_surf, (outline_width, outline_width))
|
||||
font.outline = old_outline
|
||||
return outlined_text_surf
|
||||
|
||||
.. versionadded:: 2.5.7
|
||||
|
||||
.. ## Font.outline ##
|
||||
|
||||
.. method:: render
|
||||
|
||||
| :sl:`Draw text on a new Surface.`
|
||||
| :sg:`render(text, antialias, color, bgcolor=None, wraplength=0) -> Surface`
|
||||
|
||||
This creates a new Surface with the specified text rendered on it.
|
||||
:mod:`pygame.font` provides no way to directly draw text on an existing
|
||||
Surface: instead you must use :func:`Font.render` to create an image
|
||||
(Surface) of the text, then blit this image onto another Surface.
|
||||
|
||||
Null characters ('\x00') raise a TypeError. Both Unicode and char (byte)
|
||||
strings are accepted. For Unicode strings only UCS-2 characters
|
||||
('\\u0001' to '\\uFFFF') were previously supported and any greater
|
||||
unicode codepoint would raise a UnicodeError. Now, characters in the
|
||||
UCS-4 range are supported. For char strings a ``LATIN1`` encoding is
|
||||
assumed. The antialias argument is a boolean: if True the characters
|
||||
will have smooth edges. The color argument is the color of the text
|
||||
[e.g.: (0,0,255) for blue]. The optional bgcolor argument is a color
|
||||
to use for the text background. If bgcolor is ``None`` the area outside
|
||||
the text will be transparent.
|
||||
|
||||
The `wraplength` argument describes the width (in pixels) a line of text
|
||||
should be before wrapping to a new line. See
|
||||
:attr:`pygame.font.Font.align` for line-alignment settings.
|
||||
|
||||
The Surface returned will be of the dimensions required to hold the text.
|
||||
(the same as those returned by :func:`Font.size`). If an empty string is passed
|
||||
for the text, a blank surface will be returned that is zero pixel wide and
|
||||
the height of the font.
|
||||
|
||||
Depending on the type of background and antialiasing used, this returns
|
||||
different types of Surfaces. For performance reasons, it is good to know
|
||||
what type of image will be used. If antialiasing is not used, the return
|
||||
image will always be an 8-bit image with a two-color palette. If the
|
||||
background is transparent a colorkey will be set. Antialiased images are
|
||||
rendered to 24-bit ``RGB`` images. If the background is transparent a
|
||||
pixel alpha will be included.
|
||||
|
||||
Optimization: if you know that the final destination for the text (on the
|
||||
screen) will always have a solid background, and the text is antialiased,
|
||||
you can improve performance by specifying the background color. This will
|
||||
cause the resulting image to maintain transparency information by
|
||||
colorkey rather than (much less efficient) alpha values.
|
||||
|
||||
Font rendering is not thread safe: only a single thread can render text
|
||||
at any time.
|
||||
|
||||
.. versionchangedold:: 2.0.3 Rendering UCS4 unicode works and does not
|
||||
raise an exception. Use `if hasattr(pygame.font, "UCS4"):` to see if
|
||||
pygame supports rendering UCS4 unicode including more languages and
|
||||
emoji.
|
||||
|
||||
.. versionchanged:: 2.1.4 newline characters now will break text into
|
||||
multiple lines.
|
||||
|
||||
.. versionadded:: 2.1.4 wraplength parameter
|
||||
|
||||
.. versionchanged:: 2.3.0 now supports keyword arguments.
|
||||
|
||||
.. ## Font.render ##
|
||||
|
||||
.. autopgmethod:: size
|
||||
|
||||
.. autopgmethod:: set_underline
|
||||
|
||||
.. autopgmethod:: get_underline
|
||||
|
||||
.. autopgmethod:: set_strikethrough
|
||||
|
||||
.. autopgmethod:: get_strikethrough
|
||||
|
||||
.. autopgmethod:: set_bold
|
||||
|
||||
.. autopgmethod:: get_bold
|
||||
|
||||
.. autopgmethod:: set_italic
|
||||
|
||||
.. autopgmethod:: metrics
|
||||
|
||||
.. autopgmethod:: get_italic
|
||||
|
||||
.. autopgmethod:: get_linesize
|
||||
|
||||
.. autopgmethod:: set_linesize
|
||||
|
||||
.. autopgmethod:: get_height
|
||||
|
||||
.. autopgmethod:: set_point_size
|
||||
|
||||
.. autopgmethod:: get_point_size
|
||||
|
||||
.. autopgmethod:: get_ascent
|
||||
|
||||
.. autopgmethod:: get_descent
|
||||
|
||||
.. autopgmethod:: set_script
|
||||
|
||||
.. autopgmethod:: set_direction
|
||||
|
||||
.. ## pygame.font.Font ##
|
||||
|
||||
.. ## pygame.font ##
|
||||
@@ -0,0 +1,790 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.freetype`
|
||||
======================
|
||||
|
||||
.. module:: pygame.freetype
|
||||
:synopsis: pygame module for loading and rendering computer fonts
|
||||
|
||||
| :sl:`pygame module for loading and rendering computer fonts`
|
||||
|
||||
The ``pygame.freetype`` module is an alternative to :mod:`pygame.font`.
|
||||
It is implemented directly on the FreeType 2 library, and is not
|
||||
backward compatible with :mod:`pygame.font`. :mod:`pygame.font`
|
||||
relies on the SDL_ttf library, and due to the SDL_ttf team's efforts,
|
||||
``pygame.font`` is now the better supported of our font modules.
|
||||
In new code, the use of :mod:`pygame.font` is encouraged.
|
||||
``pygame.font``, unlike ``pygame.freetype``, has support for multiline text,
|
||||
text shaping for global writing systems, and rendering emoji with color.
|
||||
|
||||
The ``pygame.ftfont`` module exists as a limited version of
|
||||
the :mod:`pygame.font` API, running on top of ``pygame.freetype``.
|
||||
Many of the recently added font features do not work on it.
|
||||
|
||||
All font file formats supported by FreeType can be rendered by
|
||||
``pygame.freetype``, namely ``TTF``, Type1, ``CFF``, OpenType,
|
||||
``SFNT``, ``PCF``, ``FNT``, ``BDF``, ``PFR`` and Type42 fonts.
|
||||
All glyphs having UTF-32 code points are accessible
|
||||
(see :attr:`Font.ucs4`).
|
||||
|
||||
Most work on fonts is done using :class:`Font` instances.
|
||||
The module itself only has routines for initialization and creation
|
||||
of :class:`Font` objects.
|
||||
You can load fonts from the system using the :func:`SysFont` function.
|
||||
|
||||
Extra support of bitmap fonts is available. Available bitmap sizes can
|
||||
be listed (see :meth:`Font.get_sizes`). For bitmap only fonts :class:`Font`
|
||||
can set the size for you (see the :attr:`Font.size` property).
|
||||
|
||||
For now undefined character codes are replaced with the ``.notdef``
|
||||
(not defined) character.
|
||||
How undefined codes are handled may become configurable in a future release.
|
||||
|
||||
Pygame comes with a built-in default font. This can always be accessed by
|
||||
passing None as the font name to the :class:`Font` constructor.
|
||||
|
||||
Extra rendering features available to :class:`pygame.freetype.Font`
|
||||
are direct to surface rendering (see :meth:`Font.render_to`), character kerning
|
||||
(see :attr:`Font.kerning`), vertical layout (see :attr:`Font.vertical`),
|
||||
rotation of rendered text (see :attr:`Font.rotation`),
|
||||
and the strong style (see :attr:`Font.strong`).
|
||||
Some properties are configurable, such as
|
||||
strong style strength (see :attr:`Font.strength`) and underline positioning
|
||||
(see :attr:`Font.underline_adjustment`). Text can be positioned by the upper
|
||||
right corner of the text box or by the text baseline (see :attr:`Font.origin`).
|
||||
Finally, a font's vertical and horizontal size can be adjusted separately
|
||||
(see :attr:`Font.size`).
|
||||
The :any:`pygame.examples.freetype_misc <pygame.examples.freetype_misc.main>`
|
||||
example shows these features in use.
|
||||
|
||||
The pygame package does not import ``freetype`` automatically when
|
||||
loaded. This module must be imported explicitly to be used. ::
|
||||
|
||||
import pygame
|
||||
import pygame.freetype
|
||||
|
||||
.. versionaddedold:: 1.9.2 :mod:`freetype`
|
||||
|
||||
|
||||
.. function:: get_error
|
||||
|
||||
| :sl:`Return the latest FreeType error`
|
||||
| :sg:`get_error() -> str`
|
||||
| :sg:`get_error() -> None`
|
||||
|
||||
Return a description of the last error which occurred in the FreeType2
|
||||
library, or ``None`` if no errors have occurred.
|
||||
|
||||
.. function:: get_version
|
||||
|
||||
| :sl:`Return the FreeType version`
|
||||
| :sg:`get_version(linked=True) -> (int, int, int)`
|
||||
|
||||
Returns the version of the FreeType library in use by this module. ``linked=True``
|
||||
is the default behavior and returns the linked version of FreeType and ``linked=False``
|
||||
returns the compiled version of FreeType.
|
||||
|
||||
Note that the ``freetype`` module depends on the FreeType 2 library.
|
||||
It will not compile with the original FreeType 1.0. Hence, the first element
|
||||
of the tuple will always be "2".
|
||||
|
||||
.. versionchanged:: 2.1.4 ``linked`` keyword argument added and default behavior changed from returning compiled version to returning linked version
|
||||
|
||||
.. function:: init
|
||||
|
||||
| :sl:`Initialize the underlying FreeType library.`
|
||||
| :sg:`init(cache_size=64, resolution=72) -> None`
|
||||
|
||||
This function initializes the underlying FreeType library and must be
|
||||
called before trying to use any of the functionality of the ``freetype``
|
||||
module.
|
||||
|
||||
However, :func:`pygame.init()` will automatically call this function
|
||||
if the ``freetype`` module is already imported. It is safe to call this
|
||||
function more than once.
|
||||
|
||||
Optionally, you may specify a default *cache_size* for the Glyph cache: the
|
||||
maximum number of glyphs that will be cached at any given time by the
|
||||
module. Exceedingly small values will be automatically tuned for
|
||||
performance. Also a default pixel *resolution*, in dots per inch, can
|
||||
be given to adjust font scaling.
|
||||
|
||||
.. function:: quit
|
||||
|
||||
| :sl:`Shut down the underlying FreeType library.`
|
||||
| :sg:`quit() -> None`
|
||||
|
||||
This function closes the ``freetype`` module. After calling this
|
||||
function, you should not invoke any class, method or function related to the
|
||||
``freetype`` module as they are likely to fail or might give unpredictable
|
||||
results. It is safe to call this function even if the module hasn't been
|
||||
initialized yet.
|
||||
|
||||
.. function:: get_init
|
||||
|
||||
| :sl:`Returns True if the FreeType module is currently initialized.`
|
||||
| :sg:`get_init() -> bool`
|
||||
|
||||
Returns ``True`` if the ``pygame.freetype`` module is currently initialized.
|
||||
|
||||
.. versionaddedold:: 1.9.5
|
||||
|
||||
.. function:: was_init
|
||||
|
||||
| :sl:`DEPRECATED: Use get_init() instead.`
|
||||
| :sg:`was_init() -> bool`
|
||||
|
||||
DEPRECATED: Returns ``True`` if the ``pygame.freetype`` module is currently
|
||||
initialized. Use ``get_init()`` instead.
|
||||
|
||||
.. function:: get_cache_size
|
||||
|
||||
| :sl:`Return the glyph case size`
|
||||
| :sg:`get_cache_size() -> long`
|
||||
|
||||
See :func:`pygame.freetype.init()`.
|
||||
|
||||
.. function:: get_default_resolution
|
||||
|
||||
| :sl:`Return the default pixel size in dots per inch`
|
||||
| :sg:`get_default_resolution() -> long`
|
||||
|
||||
Returns the default pixel size, in dots per inch, for the module.
|
||||
The default is 72 DPI.
|
||||
|
||||
.. function:: set_default_resolution
|
||||
|
||||
| :sl:`Set the default pixel size in dots per inch for the module`
|
||||
| :sg:`set_default_resolution(resolution, /)`
|
||||
|
||||
Set the default pixel size, in dots per inch, for the module. If the
|
||||
optional argument is omitted or zero the resolution is reset to 72 DPI.
|
||||
|
||||
.. function:: SysFont
|
||||
|
||||
| :sl:`create a Font object from the system fonts`
|
||||
| :sg:`SysFont(name, size, bold=False, italic=False) -> Font`
|
||||
|
||||
Return a new Font object that is loaded from the system fonts. The font will
|
||||
match the requested *bold* and *italic* flags. Pygame uses a small set of
|
||||
common font aliases. If the specific font you ask for is not available, a
|
||||
reasonable alternative may be used. If a suitable system font is not found
|
||||
this will fall back on loading the default pygame font.
|
||||
|
||||
The font *name* can also be an iterable of font names, a string of
|
||||
comma-separated font names, or a bytes of comma-separated font names, in
|
||||
which case the set of names will be searched in order.
|
||||
|
||||
.. versionaddedold:: 2.0.1 Accept an iterable of font names.
|
||||
|
||||
.. function:: get_default_font
|
||||
|
||||
| :sl:`Get the filename of the default font`
|
||||
| :sg:`get_default_font() -> string`
|
||||
|
||||
Return the filename of the default pygame font. This is not the full path
|
||||
to the file. The file is usually in the same directory as the font module,
|
||||
but can also be bundled in a separate archive.
|
||||
|
||||
.. class:: Font
|
||||
|
||||
| :sl:`Create a new Font instance from a supported font file.`
|
||||
| :sg:`Font(file, size=0, font_index=0, resolution=0, ucs4=False) -> Font`
|
||||
| :sg:`Font(pathlib.Path) -> Font`
|
||||
|
||||
Argument *file* can be either a string representing the font's filename, a
|
||||
file-like object containing the font, or None; if None, a default,
|
||||
Pygame, font is used.
|
||||
|
||||
.. _freetype-font-size-argument:
|
||||
|
||||
Optionally, a *size* argument may be specified to set the default size in
|
||||
points, which determines the size of the rendered characters.
|
||||
The size can also be passed explicitly to each method call.
|
||||
Because of the way the caching system works, specifying a default size on
|
||||
the constructor doesn't imply a performance gain over manually passing
|
||||
the size on each function call. If the font is bitmap and no *size*
|
||||
is given, the default size is set to the first available size for the font.
|
||||
|
||||
If the font file has more than one font, the font to load can be chosen with
|
||||
the *index* argument. An exception is raised for an out-of-range font index
|
||||
value.
|
||||
|
||||
The optional *resolution* argument sets the pixel size, in dots per inch,
|
||||
for use in scaling glyphs for this Font instance. If 0 then the default
|
||||
module value, set by :func:`init`, is used. The Font object's
|
||||
resolution can only be changed by re-initializing the Font instance.
|
||||
|
||||
The optional *ucs4* argument, an integer, sets the default text translation
|
||||
mode: 0 (False) recognize UTF-16 surrogate pairs, any other value (True),
|
||||
to treat Unicode text as UCS-4, with no surrogate pairs. See
|
||||
:attr:`Font.ucs4`.
|
||||
|
||||
.. attribute:: name
|
||||
|
||||
| :sl:`Proper font name.`
|
||||
| :sg:`name -> string`
|
||||
|
||||
Read only. Returns the real (long) name of the font, as
|
||||
recorded in the font file.
|
||||
|
||||
.. attribute:: style_name
|
||||
|
||||
| :sl:`Gets the font's style_name.`
|
||||
| :sg:`style_name -> str`
|
||||
|
||||
Read only. Returns the font's style name. Style names are arbitrary, can be an empty string.
|
||||
Here are some examples:
|
||||
|
||||
'Black', 'Bold', 'Bold Italic', 'BoldOblique', 'Book', 'BookOblique', 'Condensed', 'Condensed Oblique',
|
||||
'ExtraLight', 'Italic', 'Light', 'LightOblique', 'Medium', 'MediumOblique', 'Oblique', 'Regular',
|
||||
'Semibold', 'Semilight', 'Slanted'
|
||||
|
||||
.. versionadded:: 2.3.1
|
||||
|
||||
.. ## Font.style_name ##
|
||||
|
||||
.. attribute:: path
|
||||
|
||||
| :sl:`Font file path`
|
||||
| :sg:`path -> unicode`
|
||||
|
||||
Read only. Returns the path of the loaded font file
|
||||
|
||||
.. attribute:: size
|
||||
|
||||
| :sl:`The default point size used in rendering`
|
||||
| :sg:`size -> float`
|
||||
| :sg:`size -> (float, float)`
|
||||
|
||||
Get or set the default size for text metrics and rendering. It can be
|
||||
a single point size, given as a Python ``int`` or ``float``, or a
|
||||
font ppem (width, height) ``tuple``. Size values are non-negative.
|
||||
A zero size or width represents an undefined size. In this case
|
||||
the size must be given as a method argument, or an exception is
|
||||
raised. A zero width but non-zero height is a ValueError.
|
||||
|
||||
For a scalable font, a single number value is equivalent to a tuple
|
||||
with width equal height. A font can be stretched vertically with
|
||||
height set greater than width, or horizontally with width set
|
||||
greater than height. For embedded bitmaps, as listed by :meth:`get_sizes`,
|
||||
use the nominal width and height to select an available size.
|
||||
|
||||
Font size differs for a non-scalable, bitmap, font. During a
|
||||
method call it must match one of the available sizes returned by
|
||||
method :meth:`get_sizes`. If not, an exception is raised.
|
||||
If the size is a single number, the size is first matched against the
|
||||
point size value. If no match, then the available size with the
|
||||
same nominal width and height is chosen.
|
||||
|
||||
.. method:: get_rect
|
||||
|
||||
| :sl:`Return the size and offset of rendered text`
|
||||
| :sg:`get_rect(text, style=STYLE_DEFAULT, rotation=0, size=0) -> rect`
|
||||
|
||||
Gets the final dimensions and origin, in pixels, of *text* using the
|
||||
optional *size* in points, *style*, and *rotation*. For other
|
||||
relevant render properties, and for any optional argument not given,
|
||||
the default values set for the :class:`Font` instance are used.
|
||||
|
||||
Returns a :class:`Rect <pygame.Rect>` instance containing the
|
||||
width and height of the text's bounding box and the position of the
|
||||
text's origin.
|
||||
The origin is useful in aligning separately rendered pieces of text.
|
||||
It gives the baseline position and bearing at the start of the text.
|
||||
See the :meth:`render_to` method for an example.
|
||||
|
||||
If *text* is a char (byte) string, its encoding is assumed to be
|
||||
``LATIN1``.
|
||||
|
||||
Optionally, *text* can be ``None``, which will return the bounding
|
||||
rectangle for the text passed to a previous :meth:`get_rect`,
|
||||
:meth:`render`, :meth:`render_to`, :meth:`render_raw`, or
|
||||
:meth:`render_raw_to` call. See :meth:`render_to` for more
|
||||
details.
|
||||
|
||||
.. method:: get_metrics
|
||||
|
||||
| :sl:`Return the glyph metrics for the given text`
|
||||
| :sg:`get_metrics(text, size=0) -> [(...), ...]`
|
||||
|
||||
Returns the glyph metrics for each character in *text*.
|
||||
|
||||
The glyph metrics are returned as a list of tuples. Each tuple gives
|
||||
metrics of a single character glyph. The glyph metrics are:
|
||||
|
||||
::
|
||||
|
||||
(min_x, max_x, min_y, max_y, horizontal_advance_x, horizontal_advance_y)
|
||||
|
||||
The bounding box min_x, max_x, min_y, and max_y values are returned as
|
||||
grid-fitted pixel coordinates of type int. The advance values are
|
||||
float values.
|
||||
|
||||
The calculations are done using the font's default size in points.
|
||||
Optionally you may specify another point size with the *size* argument.
|
||||
|
||||
The metrics are adjusted for the current rotation, strong, and oblique
|
||||
settings.
|
||||
|
||||
If text is a char (byte) string, then its encoding is assumed to be
|
||||
``LATIN1``.
|
||||
|
||||
.. attribute:: height
|
||||
|
||||
| :sl:`The unscaled height of the font in font units`
|
||||
| :sg:`height -> int`
|
||||
|
||||
Read only. Gets the height of the font. This is the average value of all
|
||||
glyphs in the font.
|
||||
|
||||
.. attribute:: ascender
|
||||
|
||||
| :sl:`The unscaled ascent of the font in font units`
|
||||
| :sg:`ascender -> int`
|
||||
|
||||
Read only. Return the number of units from the font's baseline to
|
||||
the top of the bounding box.
|
||||
|
||||
.. attribute:: descender
|
||||
|
||||
| :sl:`The unscaled descent of the font in font units`
|
||||
| :sg:`descender -> int`
|
||||
|
||||
Read only. Return the height in font units for the font descent.
|
||||
The descent is the number of units from the font's baseline to the
|
||||
bottom of the bounding box.
|
||||
|
||||
.. method:: get_sized_ascender
|
||||
|
||||
| :sl:`The scaled ascent of the font in pixels`
|
||||
| :sg:`get_sized_ascender(size=0, /) -> int`
|
||||
|
||||
Return the number of units from the font's baseline to the top of the
|
||||
bounding box. It is not adjusted for strong or rotation.
|
||||
|
||||
.. method:: get_sized_descender
|
||||
|
||||
| :sl:`The scaled descent of the font in pixels`
|
||||
| :sg:`get_sized_descender(size=0, /) -> int`
|
||||
|
||||
Return the number of pixels from the font's baseline to the bottom of the
|
||||
bounding box. It is not adjusted for strong or rotation.
|
||||
|
||||
.. method:: get_sized_height
|
||||
|
||||
| :sl:`The scaled height of the font in pixels`
|
||||
| :sg:`get_sized_height(size=0, /) -> int`
|
||||
|
||||
Returns the height of the font. This is the average value of all
|
||||
glyphs in the font. It is not adjusted for strong or rotation.
|
||||
|
||||
.. method:: get_sized_glyph_height
|
||||
|
||||
| :sl:`The scaled bounding box height of the font in pixels`
|
||||
| :sg:`get_sized_glyph_height(size=0, /) -> int`
|
||||
|
||||
Return the glyph bounding box height of the font in pixels.
|
||||
This is the average value of all glyphs in the font.
|
||||
It is not adjusted for strong or rotation.
|
||||
|
||||
.. method:: get_sizes
|
||||
|
||||
| :sl:`return the available sizes of embedded bitmaps`
|
||||
| :sg:`get_sizes() -> [(int, int, int, float, float), ...]`
|
||||
| :sg:`get_sizes() -> []`
|
||||
|
||||
Returns a list of tuple records, one for each point size
|
||||
supported. Each tuple containing the point size, the height in pixels,
|
||||
width in pixels, horizontal ppem (nominal width) in fractional pixels,
|
||||
and vertical ppem (nominal height) in fractional pixels.
|
||||
|
||||
.. method:: render
|
||||
|
||||
| :sl:`Return rendered text as a surface`
|
||||
| :sg:`render(text, fgcolor=None, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> (Surface, Rect)`
|
||||
|
||||
Returns a new :class:`Surface <pygame.Surface>`,
|
||||
with the text rendered to it
|
||||
in the color given by 'fgcolor'. If no foreground color is given,
|
||||
the default foreground color, :attr:`fgcolor <Font.fgcolor>` is used.
|
||||
If ``bgcolor`` is given, the surface
|
||||
will be filled with this color. When no background color is given,
|
||||
the surface background is transparent, zero alpha. Normally the returned
|
||||
surface has a 32 bit pixel size. However, if ``bgcolor`` is ``None``
|
||||
and anti-aliasing is disabled a monochrome 8 bit colorkey surface,
|
||||
with colorkey set for the background color, is returned.
|
||||
|
||||
The return value is a tuple: the new surface and the bounding
|
||||
rectangle giving the size and origin of the rendered text.
|
||||
|
||||
If an empty string is passed for text then the returned Rect is zero
|
||||
width and the height of the font.
|
||||
|
||||
Optional *fgcolor*, *style*, *rotation*, and *size* arguments override
|
||||
the default values set for the :class:`Font` instance.
|
||||
|
||||
If *text* is a char (byte) string, then its encoding is assumed to be
|
||||
``LATIN1``.
|
||||
|
||||
Optionally, *text* can be ``None``, which will render the text
|
||||
passed to a previous :meth:`get_rect`, :meth:`render`, :meth:`render_to`,
|
||||
:meth:`render_raw`, or :meth:`render_raw_to` call.
|
||||
See :meth:`render_to` for details.
|
||||
|
||||
.. method:: render_to
|
||||
|
||||
| :sl:`Render text onto an existing surface`
|
||||
| :sg:`render_to(surf, dest, text, fgcolor=None, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> Rect`
|
||||
|
||||
Renders the string *text* to the :mod:`pygame.Surface` *surf*,
|
||||
at position *dest*, a (x, y) surface coordinate pair.
|
||||
If either x or y is not an integer it is converted to one if possible.
|
||||
Any sequence where the first two items are x and y positional elements
|
||||
is accepted, including a :class:`Rect <pygame.Rect>` instance.
|
||||
As with :meth:`render`,
|
||||
optional *fgcolor*, *style*, *rotation*, and *size* argument are
|
||||
available.
|
||||
|
||||
If a background color *bgcolor* is given, the text bounding box is
|
||||
first filled with that color. The text is blitted next.
|
||||
Both the background fill and text rendering involve full alpha blits.
|
||||
That is, the alpha values of the foreground, background, and destination
|
||||
target surface all affect the blit.
|
||||
|
||||
The return value is a rectangle giving the size and position of the
|
||||
rendered text within the surface.
|
||||
|
||||
If an empty string is passed for text then the returned
|
||||
:class:`Rect <pygame.Rect>` is zero width and the height of the font.
|
||||
The rect will test False.
|
||||
|
||||
Optionally, *text* can be set ``None``, which will re-render text
|
||||
passed to a previous :meth:`render_to`, :meth:`get_rect`, :meth:`render`,
|
||||
:meth:`render_raw`, or :meth:`render_raw_to` call. Primarily, this
|
||||
feature is an aid to using :meth:`render_to` in combination with
|
||||
:meth:`get_rect`. An example: ::
|
||||
|
||||
def word_wrap(surf, text, font, color=(0, 0, 0)):
|
||||
font.origin = True
|
||||
words = text.split(' ')
|
||||
width, height = surf.get_size()
|
||||
line_spacing = font.get_sized_height() + 2
|
||||
x, y = 0, line_spacing
|
||||
space = font.get_rect(' ')
|
||||
for word in words:
|
||||
bounds = font.get_rect(word)
|
||||
if x + bounds.width + bounds.x >= width:
|
||||
x, y = 0, y + line_spacing
|
||||
if x + bounds.width + bounds.x >= width:
|
||||
raise ValueError("word too wide for the surface")
|
||||
if y + bounds.height - bounds.y >= height:
|
||||
raise ValueError("text to long for the surface")
|
||||
font.render_to(surf, (x, y), None, color)
|
||||
x += bounds.width + space.width
|
||||
return x, y
|
||||
|
||||
When :meth:`render_to` is called with the same
|
||||
font properties ― :attr:`size`, :attr:`style`, :attr:`strength`,
|
||||
:attr:`wide`, :attr:`antialiased`, :attr:`vertical`, :attr:`rotation`,
|
||||
:attr:`kerning`, and :attr:`use_bitmap_strikes` ― as :meth:`get_rect`,
|
||||
:meth:`render_to` will use the layout calculated by :meth:`get_rect`.
|
||||
Otherwise, :meth:`render_to` will recalculate the layout if called
|
||||
with a text string or one of the above properties has changed
|
||||
after the :meth:`get_rect` call.
|
||||
|
||||
If *text* is a char (byte) string, then its encoding is assumed to be
|
||||
``LATIN1``.
|
||||
|
||||
.. method:: render_raw
|
||||
|
||||
| :sl:`Return rendered text as a string of bytes`
|
||||
| :sg:`render_raw(text, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> (bytes, (int, int))`
|
||||
|
||||
Like :meth:`render` but with the pixels returned as a byte string
|
||||
of 8-bit gray-scale values. The foreground color is 255, the
|
||||
background 0, useful as an alpha mask for a foreground pattern.
|
||||
|
||||
.. method:: render_raw_to
|
||||
|
||||
| :sl:`Render text into an array of ints`
|
||||
| :sg:`render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> Rect`
|
||||
|
||||
Render to an array object exposing an array struct interface. The array
|
||||
must be two dimensional with integer items. The default *dest* value,
|
||||
``None``, is equivalent to position (0, 0). See :meth:`render_to`.
|
||||
As with the other render methods, *text* can be ``None`` to
|
||||
render a text string passed previously to another method.
|
||||
|
||||
The return value is a :func:`pygame.Rect` giving the size and position of
|
||||
the rendered text.
|
||||
|
||||
.. attribute:: style
|
||||
|
||||
| :sl:`The font's style flags`
|
||||
| :sg:`style -> int`
|
||||
|
||||
Gets or sets the default style of the Font. This default style will be
|
||||
used for all text rendering and size calculations unless overridden
|
||||
specifically a render or :meth:`get_rect` call.
|
||||
The style value may be a bit-wise OR of one or more of the following
|
||||
constants:
|
||||
|
||||
::
|
||||
|
||||
STYLE_NORMAL
|
||||
STYLE_UNDERLINE
|
||||
STYLE_OBLIQUE
|
||||
STYLE_STRONG
|
||||
STYLE_WIDE
|
||||
STYLE_DEFAULT
|
||||
|
||||
These constants may be found on the FreeType constants module.
|
||||
Optionally, the default style can be modified or obtained accessing the
|
||||
individual style attributes (underline, oblique, strong).
|
||||
|
||||
The ``STYLE_OBLIQUE`` and ``STYLE_STRONG`` styles are for
|
||||
scalable fonts only. An attempt to set either for a bitmap font raises
|
||||
an AttributeError. An attempt to set either for an inactive font,
|
||||
as returned by ``Font.__new__()``, raises a RuntimeError.
|
||||
|
||||
Assigning ``STYLE_DEFAULT`` to the :attr:`style` property leaves
|
||||
the property unchanged, as this property defines the default.
|
||||
The :attr:`style` property will never return ``STYLE_DEFAULT``.
|
||||
|
||||
.. attribute:: underline
|
||||
|
||||
| :sl:`The state of the font's underline style flag`
|
||||
| :sg:`underline -> bool`
|
||||
|
||||
Gets or sets whether the font will be underlined when drawing text. This
|
||||
default style value will be used for all text rendering and size
|
||||
calculations unless overridden specifically in a render or
|
||||
:meth:`get_rect` call, via the 'style' parameter.
|
||||
|
||||
.. attribute:: strong
|
||||
|
||||
| :sl:`The state of the font's strong style flag`
|
||||
| :sg:`strong -> bool`
|
||||
|
||||
Gets or sets whether the font will be bold when drawing text. This
|
||||
default style value will be used for all text rendering and size
|
||||
calculations unless overridden specifically in a render or
|
||||
:meth:`get_rect` call, via the 'style' parameter.
|
||||
|
||||
.. attribute:: oblique
|
||||
|
||||
| :sl:`The state of the font's oblique style flag`
|
||||
| :sg:`oblique -> bool`
|
||||
|
||||
Gets or sets whether the font will be rendered as oblique. This
|
||||
default style value will be used for all text rendering and size
|
||||
calculations unless overridden specifically in a render or
|
||||
:meth:`get_rect` call, via the *style* parameter.
|
||||
|
||||
The oblique style is only supported for scalable (outline) fonts.
|
||||
An attempt to set this style on a bitmap font will raise an
|
||||
AttributeError. If the font object is inactive, as returned by
|
||||
``Font.__new__()``, setting this property raises a RuntimeError.
|
||||
|
||||
.. attribute:: wide
|
||||
|
||||
| :sl:`The state of the font's wide style flag`
|
||||
| :sg:`wide -> bool`
|
||||
|
||||
Gets or sets whether the font will be stretched horizontally
|
||||
when drawing text. It produces a result similar to
|
||||
:class:`pygame.font.Font`'s bold. This style not available for
|
||||
rotated text.
|
||||
|
||||
.. attribute:: strength
|
||||
|
||||
| :sl:`The strength associated with the strong or wide font styles`
|
||||
| :sg:`strength -> float`
|
||||
|
||||
The amount by which a font glyph's size is enlarged for the
|
||||
strong or wide transformations, as a fraction of the untransformed
|
||||
size. For the wide style only the horizontal dimension is
|
||||
increased. For strong text both the horizontal and vertical
|
||||
dimensions are enlarged. A wide style of strength 0.08333 ( 1/12 ) is
|
||||
equivalent to the :class:`pygame.font.Font` bold style.
|
||||
The default is 0.02778 ( 1/36 ).
|
||||
|
||||
The strength style is only supported for scalable (outline) fonts.
|
||||
An attempt to set this property on a bitmap font will raise an
|
||||
AttributeError. If the font object is inactive, as returned by
|
||||
``Font.__new__()``, assignment to this property raises a RuntimeError.
|
||||
|
||||
.. attribute:: underline_adjustment
|
||||
|
||||
| :sl:`Adjustment factor for the underline position`
|
||||
| :sg:`underline_adjustment -> float`
|
||||
|
||||
Gets or sets a factor which, when positive, is multiplied with the
|
||||
font's underline offset to adjust the underline position. A negative
|
||||
value turns an underline into a strike-through or overline. It is
|
||||
multiplied with the ascender. Accepted values range between -2.0 and 2.0
|
||||
inclusive. A value of 0.5 closely matches Tango underlining. A value of
|
||||
1.0 mimics :class:`pygame.font.Font` underlining.
|
||||
|
||||
.. attribute:: fixed_width
|
||||
|
||||
| :sl:`Gets whether the font is fixed-width`
|
||||
| :sg:`fixed_width -> bool`
|
||||
|
||||
Read only. Returns ``True`` if the font contains fixed-width
|
||||
characters (for example Courier, Bitstream Vera Sans Mono, Andale Mono).
|
||||
|
||||
.. attribute:: fixed_sizes
|
||||
|
||||
| :sl:`the number of available bitmap sizes for the font`
|
||||
| :sg:`fixed_sizes -> int`
|
||||
|
||||
Read only. Returns the number of point sizes for which the font contains
|
||||
bitmap character images. If zero then the font is not a bitmap font.
|
||||
A scalable font may contain pre-rendered point sizes as strikes.
|
||||
|
||||
.. attribute:: scalable
|
||||
|
||||
| :sl:`Gets whether the font is scalable`
|
||||
| :sg:`scalable -> bool`
|
||||
|
||||
Read only. Returns ``True`` if the font contains outline glyphs.
|
||||
If so, the point size is not limited to available bitmap sizes.
|
||||
|
||||
.. attribute:: use_bitmap_strikes
|
||||
|
||||
| :sl:`allow the use of embedded bitmaps in an outline font file`
|
||||
| :sg:`use_bitmap_strikes -> bool`
|
||||
|
||||
Some scalable fonts include embedded bitmaps for particular point
|
||||
sizes. This property controls whether or not those bitmap strikes
|
||||
are used. Set it ``False`` to disable the loading of any bitmap
|
||||
strike. Set it ``True``, the default, to permit bitmap strikes
|
||||
for a non-rotated render with no style other than :attr:`wide` or
|
||||
:attr:`underline`. This property is ignored for bitmap fonts.
|
||||
|
||||
See also :attr:`fixed_sizes` and :meth:`get_sizes`.
|
||||
|
||||
.. attribute:: antialiased
|
||||
|
||||
| :sl:`Font anti-aliasing mode`
|
||||
| :sg:`antialiased -> bool`
|
||||
|
||||
Gets or sets the font's anti-aliasing mode. This defaults to
|
||||
``True`` on all fonts, which are rendered with full 8 bit blending.
|
||||
|
||||
Set to ``False`` to do monochrome rendering. This should
|
||||
provide a small speed gain and reduce cache memory size.
|
||||
|
||||
.. attribute:: kerning
|
||||
|
||||
| :sl:`Character kerning mode`
|
||||
| :sg:`kerning -> bool`
|
||||
|
||||
Gets or sets the font's kerning mode. This defaults to ``False``
|
||||
on all fonts, which will be rendered without kerning.
|
||||
|
||||
Set to ``True`` to add kerning between character pairs, if supported
|
||||
by the font, when positioning glyphs.
|
||||
|
||||
.. attribute:: vertical
|
||||
|
||||
| :sl:`Font vertical mode`
|
||||
| :sg:`vertical -> bool`
|
||||
|
||||
Gets or sets whether the characters are laid out vertically rather
|
||||
than horizontally. May be useful when rendering Kanji or some other
|
||||
vertical script.
|
||||
|
||||
Set to ``True`` to switch to a vertical text layout. The default
|
||||
is ``False``, place horizontally.
|
||||
|
||||
Note that the :class:`Font` class does not automatically determine
|
||||
script orientation. Vertical layout must be selected explicitly.
|
||||
|
||||
Also note that several font formats (especially bitmap based ones) don't
|
||||
contain the necessary metrics to draw glyphs vertically, so drawing in
|
||||
those cases will give unspecified results.
|
||||
|
||||
.. attribute:: rotation
|
||||
|
||||
| :sl:`text rotation in degrees counterclockwise`
|
||||
| :sg:`rotation -> int`
|
||||
|
||||
Gets or sets the baseline angle of the rendered text. The angle is
|
||||
represented as integer degrees. The default angle is 0, with horizontal
|
||||
text rendered along the X-axis, and vertical text along the Y-axis.
|
||||
A positive value rotates these axes counterclockwise that many degrees.
|
||||
A negative angle corresponds to a clockwise rotation. The rotation
|
||||
value is normalized to a value within the range 0 to 359 inclusive
|
||||
(eg. 390 -> 390 - 360 -> 30, -45 -> 360 + -45 -> 315,
|
||||
720 -> 720 - (2 * 360) -> 0).
|
||||
|
||||
Only scalable (outline) fonts can be rotated. An attempt to change
|
||||
the rotation of a bitmap font raises an AttributeError.
|
||||
An attempt to change the rotation of an inactive font instance, as
|
||||
returned by ``Font.__new__()``, raises a RuntimeError.
|
||||
|
||||
.. attribute:: fgcolor
|
||||
|
||||
| :sl:`default foreground color`
|
||||
| :sg:`fgcolor -> Color`
|
||||
|
||||
Gets or sets the default glyph rendering color. It is initially opaque
|
||||
black ― (0, 0, 0, 255). Applies to :meth:`render` and :meth:`render_to`.
|
||||
|
||||
.. attribute:: bgcolor
|
||||
|
||||
| :sl:`default background color`
|
||||
| :sg:`bgcolor -> Color`
|
||||
|
||||
Gets or sets the default background rendering color. Initially it is
|
||||
unset and text will render with a transparent background by default.
|
||||
Applies to :meth:`render` and :meth:`render_to`.
|
||||
|
||||
.. versionaddedold:: 2.0.0
|
||||
|
||||
.. attribute:: origin
|
||||
|
||||
| :sl:`Font render to text origin mode`
|
||||
| :sg:`origin -> bool`
|
||||
|
||||
If set ``True``, :meth:`render_to` and :meth:`render_raw_to` will
|
||||
take the *dest* position to be that of the text origin, as opposed to
|
||||
the top-left corner of the bounding box. See :meth:`get_rect` for
|
||||
details.
|
||||
|
||||
.. attribute:: pad
|
||||
|
||||
| :sl:`padded boundary mode`
|
||||
| :sg:`pad -> bool`
|
||||
|
||||
If set ``True``, then the text boundary rectangle will be inflated
|
||||
to match that of :class:`font.Font <pygame.font.Font>`.
|
||||
Otherwise, the boundary rectangle is just large enough for the text.
|
||||
|
||||
.. attribute:: ucs4
|
||||
|
||||
| :sl:`Enable UCS-4 mode`
|
||||
| :sg:`ucs4 -> bool`
|
||||
|
||||
Gets or sets the decoding of Unicode text. By default, the
|
||||
freetype module performs UTF-16 surrogate pair decoding on Unicode text.
|
||||
This allows 32-bit escape sequences ('\Uxxxxxxxx') between 0x10000 and
|
||||
0x10FFFF to represent their corresponding UTF-32 code points on Python
|
||||
interpreters built with a UCS-2 Unicode type (on Windows, for instance).
|
||||
It also means character values within the UTF-16 surrogate area (0xD800
|
||||
to 0xDFFF) are considered part of a surrogate pair. A malformed surrogate
|
||||
pair will raise a UnicodeEncodeError. Setting ucs4 ``True`` turns
|
||||
surrogate pair decoding off, allowing access the full UCS-4 character
|
||||
range to a Python interpreter built with four-byte Unicode character
|
||||
support.
|
||||
|
||||
.. attribute:: resolution
|
||||
|
||||
| :sl:`Pixel resolution in dots per inch`
|
||||
| :sg:`resolution -> int`
|
||||
|
||||
Read only. Gets pixel size used in scaling font glyphs for this
|
||||
:class:`Font` instance.
|
||||
@@ -0,0 +1,769 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.geometry`
|
||||
======================
|
||||
|
||||
.. module:: pygame.geometry
|
||||
:synopsis: pygame geometry module
|
||||
|
||||
.. warning::
|
||||
**Experimental Module**
|
||||
|
||||
**This module is a work in progress. Refrain from relying on any features provided by
|
||||
this module, as they are subject to change or removal without prior notice.**
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
| :sl:`pygame module for the Circle, Line, and Polygon objects`
|
||||
|
||||
.. currentmodule:: pygame
|
||||
|
||||
.. class:: Circle
|
||||
|
||||
| :sl:`pygame object for representing a circle`
|
||||
| :sg:`Circle((x, y), radius) -> Circle`
|
||||
| :sg:`Circle(x, y, radius) -> Circle`
|
||||
|
||||
The `Circle` class provides many useful methods for collision testing, transformation and intersection.
|
||||
A `Circle` can be created from a combination of a pair of coordinates that represent
|
||||
the center of the circle and a radius. Circles can also be created from python objects that
|
||||
are already a `Circle` (effectively copying the circle) or have an attribute named "circle".
|
||||
|
||||
Specifically, to construct a circle you can pass the x, y, and radius values as separate
|
||||
arguments or inside a sequence(list or tuple).
|
||||
|
||||
Functions that require a `Circle` argument may also accept these values as Circles:
|
||||
|
||||
::
|
||||
|
||||
((x, y), radius)
|
||||
(x, y, radius)
|
||||
(vector2, radius)
|
||||
|
||||
The `Circle` class only stores the x, y and r attributes, everything else is calculated
|
||||
on the fly based on them.
|
||||
|
||||
**Circle Attributes**
|
||||
|
||||
----
|
||||
|
||||
.. attribute:: x
|
||||
|
||||
| :sl:`center x coordinate of the circle`
|
||||
| :sg:`x -> float`
|
||||
|
||||
The horizontal coordinate of the center of the circle. Reassigning it moves the circle.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.x ##
|
||||
|
||||
.. attribute:: y
|
||||
|
||||
| :sl:`center y coordinate of the circle`
|
||||
| :sg:`y -> float`
|
||||
|
||||
The vertical coordinate of the center of the circle. Reassigning it moves the circle.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.y ##
|
||||
|
||||
.. attribute:: r
|
||||
|
||||
| :sl:`radius of the circle`
|
||||
| :sg:`r -> float`
|
||||
|
||||
Represents the size of the circle. It can't be negative. Reassigning it scales the circle.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. versionchanged:: 2.5.1 It is now allowed to create degenerate circles with :math:`r = 0`.
|
||||
|
||||
.. ## Circle.r ##
|
||||
|
||||
.. attribute:: r_sqr
|
||||
|
||||
| :sl:`radius of the circle squared`
|
||||
| :sg:`r_sqr -> float`
|
||||
|
||||
It's equivalent to :math:`r^2`. It can't be negative. Reassigning it changes the radius to :math:`r = \sqrt{r_{sqr}}`.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.r_sqr ##
|
||||
|
||||
.. attribute:: center
|
||||
|
||||
| :sl:`x and y coordinates of the center of the circle`
|
||||
| :sg:`center -> (float, float)`
|
||||
|
||||
A tuple containing the circle's `x` and `y` coordinates representing its center.
|
||||
Reassigning it moves the circle to the new position.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.center ##
|
||||
|
||||
.. attribute:: diameter
|
||||
|
||||
| :sl:`diameter of the circle`
|
||||
| :sg:`diameter -> float`
|
||||
|
||||
It's equivalent to :math:`2 \cdot r`. It can't be negative. Reassigning it
|
||||
changes the radius to :math:`r = \frac{d}{2}`.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.diameter ##
|
||||
|
||||
.. attribute:: area
|
||||
|
||||
| :sl:`area of the circle`
|
||||
| :sg:`area -> float`
|
||||
|
||||
It's equivalent to :math:`\pi \cdot r^2`. It can't be negative. Reassigning it
|
||||
changes the radius to :math:`r = \sqrt{\frac{area}{\pi}}` producing a circle with matching area.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.area ##
|
||||
|
||||
.. attribute:: circumference
|
||||
|
||||
| :sl:`circumference of the circle`
|
||||
| :sg:`circumference -> float`
|
||||
|
||||
It's equivalent to :math:`2 \cdot \pi \cdot r`. It can't be negative. Reassigning it
|
||||
changes the radius to :math:`r = \frac{circumference}{2\pi}` producing a circle with
|
||||
matching circumference.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.circumference ##
|
||||
|
||||
.. attribute:: top
|
||||
|
||||
| :sl:`top coordinate of the circle`
|
||||
| :sg:`top -> (float, float)`
|
||||
|
||||
A tuple containing the `x` and `y` coordinates that represent the top
|
||||
of the circle.
|
||||
Reassigning it moves the circle to the new position. The radius will not be affected.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Circle.top ##
|
||||
|
||||
.. attribute:: bottom
|
||||
|
||||
| :sl:`bottom coordinate of the circle`
|
||||
| :sg:`bottom -> (float, float)`
|
||||
|
||||
A tuple containing the `x` and `y` coordinates that represent the bottom
|
||||
of the circle.
|
||||
Reassigning it moves the circle to the new position. The radius will not be affected.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Circle.bottom ##
|
||||
|
||||
.. attribute:: left
|
||||
|
||||
| :sl:`left coordinate of the circle`
|
||||
| :sg:`left -> (float, float)`
|
||||
|
||||
A tuple containing the `x` and `y` coordinates that represent the left
|
||||
of the circle.
|
||||
Reassigning it moves the circle to the new position. The radius will not be affected.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Circle.left ##
|
||||
|
||||
.. attribute:: right
|
||||
|
||||
| :sl:`right coordinate of the circle`
|
||||
| :sg:`right -> (float, float)`
|
||||
|
||||
A tuple containing the `x` and `y` coordinates that represent the right
|
||||
of the circle.
|
||||
Reassigning it moves the circle to the new position. The radius will not be affected.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Circle.right ##
|
||||
|
||||
**Circle Methods**
|
||||
|
||||
----
|
||||
|
||||
.. method:: collidepoint
|
||||
|
||||
| :sl:`tests if a point is inside the circle`
|
||||
| :sg:`collidepoint((x, y), /) -> bool`
|
||||
| :sg:`collidepoint(x, y, /) -> bool`
|
||||
| :sg:`collidepoint(vector2, /) -> bool`
|
||||
|
||||
Returns `True` if the given point is inside this `Circle` (edge included), `False` otherwise.
|
||||
It takes a tuple of (x, y) coordinates, two separate x and y coordinates, or a `Vector2`
|
||||
object as its argument.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.collidepoint ##
|
||||
|
||||
.. method:: collidecircle
|
||||
|
||||
| :sl:`tests if a circle collides with this circle`
|
||||
| :sg:`collidecircle(circle, /) -> bool`
|
||||
| :sg:`collidecircle(x, y, radius, /) -> bool`
|
||||
| :sg:`collidecircle((x, y), radius, /) -> bool`
|
||||
| :sg:`collidecircle(vector2, radius, /) -> bool`
|
||||
|
||||
Returns `True` if the given circle intersects with this `Circle`, `False` otherwise.
|
||||
It takes either a `Circle` object, a tuple of (x, y) coordinates and a radius, or separate x and y
|
||||
coordinates and a radius as its argument.
|
||||
|
||||
.. note::
|
||||
Calling this method with this circle as the argument will always return `True`.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.collidecircle ##
|
||||
|
||||
.. method:: colliderect
|
||||
|
||||
| :sl:`tests if a rectangle collides with this circle`
|
||||
| :sg:`colliderect(rect, /) -> bool`
|
||||
| :sg:`colliderect((x, y, width, height), /) -> bool`
|
||||
| :sg:`colliderect(x, y, width, height, /) -> bool`
|
||||
| :sg:`colliderect((x, y), (width, height), /) -> bool`
|
||||
| :sg:`colliderect(vector2, (width, height), /) -> bool`
|
||||
|
||||
Returns `True` if the given rectangle intersects with this `Circle`, `False` otherwise.
|
||||
Takes either a `Rect` object, a tuple of (x, y, width, height) coordinates, or separate
|
||||
x, y coordinates and width, height as its argument.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.colliderect ##
|
||||
|
||||
.. method:: collideswith
|
||||
|
||||
| :sl:`tests if a shape or point collides with this circle`
|
||||
| :sg:`collideswith(circle, /) -> bool`
|
||||
| :sg:`collideswith(rect, /) -> bool`
|
||||
| :sg:`collideswith((x, y), /) -> bool`
|
||||
| :sg:`collideswith(vector2, /) -> bool`
|
||||
|
||||
Returns `True` if the given shape or point intersects with this `Circle`, `False` otherwise.
|
||||
The shape can be a `Circle`, `Rect`, `FRect`.
|
||||
|
||||
.. note::
|
||||
The shape argument must be an actual shape object (`Circle`, `Rect`, or `FRect`).
|
||||
You can't pass a tuple or list of coordinates representing the shape (except for a point),
|
||||
because the shape type can't be determined from the coordinates alone.
|
||||
|
||||
.. versionadded:: 2.5.0
|
||||
|
||||
.. ## Circle.collideswith ##
|
||||
|
||||
.. method:: collidelist
|
||||
|
||||
| :sl:`test if a list of objects collide with the circle`
|
||||
| :sg:`collidelist(colliders) -> int`
|
||||
|
||||
The `collidelist` method tests whether a given list of shapes or points collides
|
||||
(overlaps) with this `Circle` object. The function takes in a single argument, which
|
||||
must be a list of `Circle`, `Rect`, `FRect`, or a point. The function returns the index
|
||||
of the first shape or point in the list that collides with the `Circle` object, or
|
||||
-1 if there is no collision.
|
||||
|
||||
.. note::
|
||||
The shapes must be actual shape objects, such as `Circle`, `Rect` or `FRect`
|
||||
instances. It is not possible to pass a tuple or list of coordinates representing
|
||||
the shape as an argument (except for a point), because the shape type can't be
|
||||
determined from the coordinates alone.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Circle.collidelist ##
|
||||
|
||||
.. method:: collidelistall
|
||||
|
||||
| :sl:`test if all objects in a list collide with the circle`
|
||||
| :sg:`collidelistall(colliders) -> list`
|
||||
|
||||
The `collidelistall` method tests whether a given list of shapes or points collides
|
||||
(overlaps) with this `Circle` object. The function takes in a single argument, which
|
||||
must be a list of `Circle`, `Rect`, `FRect`, or a point. The function returns a list
|
||||
containing the indices of all the shapes or points in the list that collide with
|
||||
the `Circle` object, or an empty list if there is no collision.
|
||||
|
||||
.. note::
|
||||
The shapes must be actual shape objects, such as `Circle`, `Rect` or `FRect`
|
||||
instances. It is not possible to pass a tuple or list of coordinates representing
|
||||
the shape as an argument (except for a point), because the shape type can't be
|
||||
determined from the coordinates alone.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Circle.collidelistall ##
|
||||
|
||||
.. method:: contains
|
||||
|
||||
| :sl:`tests if a shape or point is inside the circle`
|
||||
| :sg:`contains(circle, /) -> bool`
|
||||
| :sg:`contains(rect, /) -> bool`
|
||||
| :sg:`contains((x, y), /) -> bool`
|
||||
| :sg:`contains(vector2, /) -> bool`
|
||||
|
||||
Returns `True` if the shape or point is completely contained within this `Circle`, `False` otherwise.
|
||||
The shape can be a `Circle`, `Rect`, `FRect`.
|
||||
|
||||
.. note::
|
||||
The shape argument must be an actual shape object (`Circle`, `Rect`, or `FRect`).
|
||||
You can't pass a tuple or list of coordinates representing the shape (except for a point),
|
||||
because the shape type can't be determined from the coordinates alone.
|
||||
|
||||
.. versionadded:: 2.5.0
|
||||
|
||||
.. ## Circle.contains ##
|
||||
|
||||
.. method:: move
|
||||
|
||||
| :sl:`moves the circle by a given amount`
|
||||
| :sg:`move((x, y), /) -> Circle`
|
||||
| :sg:`move(x, y, /) -> Circle`
|
||||
| :sg:`move(vector2, /) -> Circle`
|
||||
|
||||
Returns a copy of this `Circle` moved by the given amounts.
|
||||
Takes either a tuple of (x, y) coordinates, two separate x and y coordinates,
|
||||
or a `Vector2` object as its argument.
|
||||
|
||||
This method is equivalent to the following code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
Circle((circle.x + x, circle.y + y), circle.r)
|
||||
|
||||
.. versionadded:: 2.5.0
|
||||
|
||||
.. ## Circle.move ##
|
||||
|
||||
.. method:: move_ip
|
||||
|
||||
| :sl:`moves the circle by a given amount, in place`
|
||||
| :sg:`move_ip((x, y), /) -> None`
|
||||
| :sg:`move_ip(x, y, /) -> None`
|
||||
| :sg:`move_ip(vector2, /) -> None`
|
||||
|
||||
Moves this `Circle` in place by the given amounts.
|
||||
Takes the same types of arguments as :meth:`move` and it always returns `None`.
|
||||
|
||||
This method is equivalent to the following code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
circle.x += x
|
||||
circle.y += y
|
||||
|
||||
.. versionadded:: 2.5.0
|
||||
|
||||
.. ## Circle.move_ip ##
|
||||
|
||||
.. method:: intersect
|
||||
|
||||
| :sl:`finds intersections between the circle and a shape`
|
||||
| :sg:`intersect(circle, /) -> list`
|
||||
|
||||
Finds and returns a list of intersection points between the circle and another shape.
|
||||
The other shape must be a `Circle` object.
|
||||
If the circle does not intersect or has infinite intersections, an empty list is returned.
|
||||
|
||||
.. note::
|
||||
The shape argument must be an instance of the `Circle` class.
|
||||
Passing a tuple or list of coordinates representing the shape is not supported,
|
||||
as the type of shape cannot be determined from coordinates alone.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Circle.intersect ##
|
||||
|
||||
.. method:: update
|
||||
|
||||
| :sl:`updates the circle position and radius`
|
||||
| :sg:`update((x, y), radius, /) -> None`
|
||||
| :sg:`update(x, y, radius, /) -> None`
|
||||
| :sg:`update(vector2, radius, /) -> None`
|
||||
|
||||
Sets the position and radius of this `Circle` to the provided values.
|
||||
It always returns `None`.
|
||||
|
||||
This method is equivalent to the following code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
circle.x = x
|
||||
circle.y = y
|
||||
circle.r = radius
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.update ##
|
||||
|
||||
.. method:: rotate
|
||||
|
||||
| :sl:`rotates the circle`
|
||||
| :sg:`rotate(angle, rotation_point=Circle.center, /) -> Circle`
|
||||
| :sg:`rotate(angle, /) -> Circle`
|
||||
|
||||
Returns a copy of this `Circle` rotated by the specified angle (in degrees) around a point.
|
||||
Positive angles rotate the circle clockwise, counter-clockwise otherwise.
|
||||
The rotation point is optional and defaults to the circle's center.
|
||||
|
||||
.. versionadded:: 2.5.0
|
||||
|
||||
.. ## Circle.rotate ##
|
||||
|
||||
.. method:: rotate_ip
|
||||
|
||||
| :sl:`rotates the circle in place`
|
||||
| :sg:`rotate_ip(angle, rotation_point=Circle.center, /) -> None`
|
||||
| :sg:`rotate_ip(angle, /) -> None`
|
||||
|
||||
Rotates the circle by a specified angle (in degrees) around a point.
|
||||
Positive angles rotate the circle clockwise, counter-clockwise otherwise.
|
||||
The rotation point is optional and defaults to the circle's center.
|
||||
|
||||
.. versionadded:: 2.5.0
|
||||
|
||||
.. ## Circle.rotate_ip ##
|
||||
|
||||
.. method:: as_rect
|
||||
|
||||
| :sl:`returns the smallest Rect containing the circle`
|
||||
| :sg:`as_rect() -> Rect`
|
||||
|
||||
Returns the smallest `pygame.Rect` object containing this `Circle`.
|
||||
|
||||
This method is equivalent to the following code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
Rect(circle.x - circle.r, circle.y - circle.r, circle.r * 2, circle.r * 2)
|
||||
|
||||
.. versionadded:: 2.5.0
|
||||
|
||||
.. ## Circle.as_rect ##
|
||||
|
||||
.. method:: as_frect
|
||||
|
||||
| :sl:`returns the smallest FRect containing the circle`
|
||||
| :sg:`as_frect() -> FRect`
|
||||
|
||||
Returns the smallest `pygame.FRect` object containing this `Circle`.
|
||||
|
||||
This method is equivalent to the following code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
FRect(circle.x - circle.r, circle.y - circle.r, circle.r * 2, circle.r * 2)
|
||||
|
||||
.. versionadded:: 2.5.0
|
||||
|
||||
.. ## Circle.as_frect ##
|
||||
|
||||
.. method:: copy
|
||||
|
||||
| :sl:`copies the circle`
|
||||
| :sg:`copy() -> Circle`
|
||||
|
||||
Returns a copy of this `Circle`.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Circle.copy ##
|
||||
|
||||
.. ## pygame.Circle ##
|
||||
|
||||
|
||||
.. class:: Line
|
||||
|
||||
| :sl:`pygame object for representing a line`
|
||||
| :sg:`Line((ax, ay), (bx, by)) -> Line`
|
||||
| :sg:`Line(ax, ay, bx, by) -> Line`
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
The `Line` class provides many useful methods for collision testing, transformation and intersection.
|
||||
A `Line` can be created from a combination of two pairs of coordinates that represent the start and end points.
|
||||
Lines can also be created from python objects that are already a `Line` (effectively copying the line) or have an attribute named "line".
|
||||
|
||||
Specifically, to construct a `Line` you can pass the ax, ay, bx, and by values as separate
|
||||
arguments or inside a sequence(list or tuple).
|
||||
|
||||
As a special case you can also pass in `pygame.Rect` / `pygame.FRect`, in which case the
|
||||
line will be created with (x, y, width, height) as the start and end points.
|
||||
|
||||
You can create lines with the same start and end points, but beware that some methods may
|
||||
not work as expected or error out.
|
||||
|
||||
Functions that require a `Line` argument may also accept these values as Lines:
|
||||
|
||||
::
|
||||
|
||||
((ax, ay), (bx, by))
|
||||
(ax, ay, bx, by)
|
||||
(vector2, vector2)
|
||||
|
||||
The `Line` class only stores the ax, ay, bx, and by attributes, everything else is calculated
|
||||
on the fly based on them.
|
||||
|
||||
**Line Attributes**
|
||||
|
||||
----
|
||||
|
||||
.. attribute:: ax
|
||||
|
||||
| :sl:`x coordinate of the start point of the line`
|
||||
| :sg:`ax -> float`
|
||||
|
||||
The horizontal coordinate of the start point of the line. Reassigning it moves the line.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Line.ax ##
|
||||
|
||||
.. attribute:: ay
|
||||
|
||||
| :sl:`y coordinate of the start point of the line`
|
||||
| :sg:`ay -> float`
|
||||
|
||||
The vertical coordinate of the start point of the line. Reassigning it moves the line.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Line.ay ##
|
||||
|
||||
.. attribute:: bx
|
||||
|
||||
| :sl:`x coordinate of the end point of the line`
|
||||
| :sg:`bx -> float`
|
||||
|
||||
The horizontal coordinate of the end point of the line. Reassigning it moves the line.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Line.bx ##
|
||||
|
||||
.. attribute:: by
|
||||
|
||||
| :sl:`y coordinate of the end point of the line`
|
||||
| :sg:`by -> float`
|
||||
|
||||
The vertical coordinate of the end point of the line. Reassigning it moves the line.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Line.by ##
|
||||
|
||||
.. attribute:: a
|
||||
|
||||
| :sl:`the first point of the line`
|
||||
| :sg:`a -> (float, float)`
|
||||
|
||||
A tuple containing the `ax` and `ay` attributes representing the line's first point.
|
||||
It can be reassigned to move the `Line`. If reassigned the `ax` and `ay` attributes
|
||||
will be changed to produce a `Line` with matching first point position.
|
||||
The `bx` and `by` attributes will not be affected.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Line.a ##
|
||||
|
||||
.. attribute:: b
|
||||
|
||||
| :sl:`the second point of the line`
|
||||
| :sg:`b -> (float, float)`
|
||||
|
||||
A tuple containing `bx` and `by` attributes representing the line's second point.
|
||||
It can be reassigned to move the `Line`. If reassigned the `bx` and `by` attributes
|
||||
will be changed to produce a `Line` with matching second point position.
|
||||
The `ax` and `ay` attributes will not be affected.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Line.b ##
|
||||
|
||||
.. attribute:: length
|
||||
|
||||
| :sl:`the length of the line`
|
||||
| :sg:`length -> float`
|
||||
|
||||
The length of the line. Calculated using the `sqrt((bx-ax)**2 + (by-ay)**2)` formula.
|
||||
This attribute is read-only, it cannot be reassigned. To change the line's length
|
||||
use the `scale` method or change its `a` or `b` attributes.
|
||||
|
||||
.. versionadded:: 2.5.3
|
||||
|
||||
.. ## Line.length ##
|
||||
|
||||
**Line Methods**
|
||||
|
||||
----
|
||||
|
||||
.. method:: copy
|
||||
|
||||
| :sl:`copies the line`
|
||||
| :sg:`copy() -> Line`
|
||||
|
||||
Returns a copy of this `Line`.
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
.. ## Line.copy ##
|
||||
|
||||
.. method:: move
|
||||
|
||||
| :sl:`moves the line by a given amount`
|
||||
| :sg:`move((x, y)) -> Line`
|
||||
| :sg:`move(x, y) -> Line`
|
||||
|
||||
Returns a new `Line` that is moved by the given offset. The original `Line` is
|
||||
not modified.
|
||||
|
||||
This method is equivalent to the following code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
Line(line.ax + x, line.ay + y, line.bx + x, line.by + y)
|
||||
|
||||
.. versionadded:: 2.5.3
|
||||
|
||||
.. ## Line.move ##
|
||||
|
||||
.. method:: move_ip
|
||||
|
||||
| :sl:`moves the line by a given amount`
|
||||
| :sg:`move_ip((x, y)) -> None`
|
||||
| :sg:`move_ip(x, y) -> None`
|
||||
|
||||
Moves the `Line` by the given offset. The original `Line` is modified. Always returns
|
||||
`None`.
|
||||
|
||||
This method is equivalent to the following code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
line.ax += x
|
||||
line.ay += y
|
||||
line.bx += x
|
||||
line.by += y
|
||||
|
||||
.. versionadded:: 2.5.3
|
||||
|
||||
.. ## Line.move_ip ##
|
||||
|
||||
.. method:: update
|
||||
|
||||
| :sl:`updates the line's attributes`
|
||||
| :sg:`update((ax, ay), (bx, by)) -> None`
|
||||
| :sg:`update(ax, ay, bx, by) -> None`
|
||||
| :sg:`update(line) -> None`
|
||||
|
||||
Updates the `Line`'s attributes. The original `Line` is modified. Always returns `None`.
|
||||
|
||||
This method is equivalent to the following code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
line.ax = ax
|
||||
line.ay = ay
|
||||
line.bx = bx
|
||||
line.by = by
|
||||
|
||||
.. versionadded:: 2.5.3
|
||||
|
||||
.. ## Line.update ##
|
||||
|
||||
.. method:: scale
|
||||
|
||||
| :sl:`scales the line by the given factor from the given origin`
|
||||
| :sg:`scale(factor, origin) -> Line`
|
||||
| :sg:`scale(factor_and_origin) -> Line`
|
||||
|
||||
Returns a new `Line` which is scaled by the given factor from the specified origin with 0.0 being
|
||||
the starting point, 0.5 being the center and 1.0 being the end point.
|
||||
The original `Line` is not modified.
|
||||
|
||||
.. versionadded:: 2.5.3
|
||||
|
||||
.. ## Line.scale ##
|
||||
|
||||
.. method:: scale_ip
|
||||
|
||||
| :sl:`scales the line by the given factor from the given origin in place`
|
||||
| :sg:`scale_ip(factor, origin) -> None`
|
||||
| :sg:`scale_ip(factor_and_origin) -> None`
|
||||
|
||||
Scales the `Line` by the given factor from the specified origin with 0.0 being
|
||||
the starting point, 0.5 being the center and 1.0 being the end point.
|
||||
The original `Line` is modified.
|
||||
Always returns `None`.
|
||||
|
||||
.. versionadded:: 2.5.3
|
||||
|
||||
.. ## Line.scale_ip ##
|
||||
|
||||
.. method:: flip_ab
|
||||
|
||||
| :sl:`flips the line a and b points`
|
||||
| :sg:`flip_ab() -> Line`
|
||||
|
||||
Returns a new `Line` that has the `a` and `b` points flipped.
|
||||
The original `Line` is not modified.
|
||||
|
||||
.. versionadded:: 2.5.3
|
||||
|
||||
.. ## Line.flip_ab ##
|
||||
|
||||
.. method:: flip_ab_ip
|
||||
|
||||
| :sl:`flips the line a and b points, in place`
|
||||
| :sg:`flip_ab_ip() -> None`
|
||||
|
||||
Flips the `Line`'s `a` and `b` points. The original `Line` is modified.
|
||||
Always returns `None`.
|
||||
|
||||
.. versionadded:: 2.5.3
|
||||
|
||||
.. ## Line.flip_ab_ip ##
|
||||
|
||||
.. method:: project
|
||||
|
||||
| :sl:`projects the line onto the given line`
|
||||
| :sg:`project(point: tuple[float, float], clamp=False) -> tuple[float, float]`
|
||||
|
||||
This method takes in a point and one boolean keyword argument clamp. It outputs an orthogonally projected point onto the line.
|
||||
If clamp is `True` it makes sure that the outputted point will be on the line segment (which might not be orthogonal), and if it is `False` (the default) then any point on the infinitely extended line may be outputted.
|
||||
This method can be used to find the closest point on a line to the given point. The output is the unique point on the line or line segment that is the smallest distance away from the given point.
|
||||
|
||||
|
||||
.. figure:: code_examples/project.png
|
||||
:alt: project method image
|
||||
|
||||
Example of how it projects the point onto the line. The red point is the point we want to project and the blue point is what you would get as a result.
|
||||
|
||||
|
||||
.. figure:: code_examples/project_clamp.png
|
||||
:alt: project clamp argument image
|
||||
|
||||
Example of what the clamp argument changes. If it is `True`, the point is bounded between the line segment ends.
|
||||
|
||||
WARNING: If the line has no length (i.e. the start and end points are the same) then the returned point of this function will be the same point as both ends of the line.
|
||||
|
||||
.. versionadded:: 2.5.6
|
||||
|
||||
.. ## Line.project ##
|
||||
@@ -0,0 +1,631 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.gfxdraw`
|
||||
=====================
|
||||
|
||||
.. module:: pygame.gfxdraw
|
||||
:synopsis: pygame module for drawing shapes
|
||||
|
||||
| :sl:`pygame module for drawing shapes`
|
||||
|
||||
**EXPERIMENTAL!**: This API may change or disappear in later pygame releases. If
|
||||
you use this, your code may break with the next pygame release.
|
||||
|
||||
The pygame package does not import gfxdraw automatically when loaded, so it
|
||||
must imported explicitly to be used.
|
||||
|
||||
::
|
||||
|
||||
import pygame
|
||||
import pygame.gfxdraw
|
||||
|
||||
For all functions the arguments are strictly positional and integers are
|
||||
accepted for coordinates and radii. The ``color`` argument can be one of the
|
||||
following formats:
|
||||
|
||||
- a :mod:`pygame.Color` object
|
||||
- an ``(RGB)`` triplet (tuple/list)
|
||||
- an ``(RGBA)`` quadruplet (tuple/list)
|
||||
|
||||
The functions :meth:`rectangle` and :meth:`box` will accept any ``(x, y, w, h)``
|
||||
sequence for their ``rect`` argument, though :mod:`pygame.Rect` instances are
|
||||
preferred.
|
||||
|
||||
To draw a filled antialiased shape, first use the antialiased (aa*) version
|
||||
of the function, and then use the filled (filled_*) version.
|
||||
For example:
|
||||
|
||||
::
|
||||
|
||||
col = (255, 0, 0)
|
||||
surf.fill((255, 255, 255))
|
||||
pygame.gfxdraw.aacircle(surf, x, y, 30, col)
|
||||
pygame.gfxdraw.filled_circle(surf, x, y, 30, col)
|
||||
|
||||
|
||||
.. note::
|
||||
For threading, each of the functions releases the GIL during the C part of
|
||||
the call.
|
||||
|
||||
.. note::
|
||||
See the :mod:`pygame.draw` module for alternative draw methods.
|
||||
The ``pygame.gfxdraw`` module differs from the :mod:`pygame.draw` module in
|
||||
the API it uses and the different draw functions available.
|
||||
``pygame.gfxdraw`` wraps the primitives from the library called SDL_gfx,
|
||||
rather than using modified versions.
|
||||
|
||||
.. versionaddedold:: 1.9.0
|
||||
|
||||
|
||||
.. function:: pixel
|
||||
|
||||
| :sl:`draw a pixel`
|
||||
| :sg:`pixel(surface, x, y, color, /) -> None`
|
||||
|
||||
Draws a single pixel, at position (x ,y), on the given surface.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x: x coordinate of the pixel
|
||||
:param int y: y coordinate of the pixel
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.pixel ##
|
||||
|
||||
.. function:: hline
|
||||
|
||||
| :sl:`draw a horizontal line`
|
||||
| :sg:`hline(surface, x1, x2, y, color, /) -> None`
|
||||
|
||||
Draws a straight horizontal line (``(x1, y)`` to ``(x2, y)``) on the given
|
||||
surface. There are no endcaps.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x1: x coordinate of one end of the line
|
||||
:param int x2: x coordinate of the other end of the line
|
||||
:param int y: y coordinate of the line
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.hline ##
|
||||
|
||||
.. function:: vline
|
||||
|
||||
| :sl:`draw a vertical line`
|
||||
| :sg:`vline(surface, x, y1, y2, color, /) -> None`
|
||||
|
||||
Draws a straight vertical line (``(x, y1)`` to ``(x, y2)``) on the given
|
||||
surface. There are no endcaps.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x: x coordinate of the line
|
||||
:param int y1: y coordinate of one end of the line
|
||||
:param int y2: y coordinate of the other end of the line
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.vline ##
|
||||
|
||||
.. function:: line
|
||||
|
||||
| :sl:`draw a line`
|
||||
| :sg:`line(surface, x1, y1, x2, y2, color, /) -> None`
|
||||
|
||||
Draws a straight line (``(x1, y1)`` to ``(x2, y2)``) on the given surface.
|
||||
There are no endcaps.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x1: x coordinate of one end of the line
|
||||
:param int y1: y coordinate of one end of the line
|
||||
:param int x2: x coordinate of the other end of the line
|
||||
:param int y2: y coordinate of the other end of the line
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.line ##
|
||||
|
||||
.. function:: rectangle
|
||||
|
||||
| :sl:`draw a rectangle`
|
||||
| :sg:`rectangle(surface, rect, color, /) -> None`
|
||||
|
||||
Draws an unfilled rectangle on the given surface. For a filled rectangle use
|
||||
:meth:`box`.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param Rect rect: rectangle to draw, position and dimensions
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. note::
|
||||
The ``rect.bottom`` and ``rect.right`` attributes of a :mod:`pygame.Rect`
|
||||
always lie one pixel outside of its actual border. Therefore, these
|
||||
values will not be included as part of the drawing.
|
||||
|
||||
.. ## pygame.gfxdraw.rectangle ##
|
||||
|
||||
.. function:: box
|
||||
|
||||
| :sl:`draw a filled rectangle`
|
||||
| :sg:`box(surface, rect, color, /) -> None`
|
||||
|
||||
Draws a filled rectangle on the given surface. For an unfilled rectangle use
|
||||
:meth:`rectangle`.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param Rect rect: rectangle to draw, position and dimensions
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. note::
|
||||
The ``rect.bottom`` and ``rect.right`` attributes of a :mod:`pygame.Rect`
|
||||
always lie one pixel outside of its actual border. Therefore, these
|
||||
values will not be included as part of the drawing.
|
||||
|
||||
.. note::
|
||||
The :func:`pygame.Surface.fill` method works just as well for drawing
|
||||
filled rectangles. In fact :func:`pygame.Surface.fill` can be hardware
|
||||
accelerated on some platforms with both software and hardware display
|
||||
modes.
|
||||
|
||||
.. ## pygame.gfxdraw.box ##
|
||||
|
||||
.. function:: circle
|
||||
|
||||
| :sl:`draw a circle`
|
||||
| :sg:`circle(surface, x, y, r, color, /) -> None`
|
||||
|
||||
Draws an unfilled circle on the given surface. For a filled circle use
|
||||
:meth:`filled_circle`.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x: x coordinate of the center of the circle
|
||||
:param int y: y coordinate of the center of the circle
|
||||
:param int r: radius of the circle
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.circle ##
|
||||
|
||||
.. function:: aacircle
|
||||
|
||||
| :sl:`draw an antialiased circle`
|
||||
| :sg:`aacircle(surface, x, y, r, color, /) -> None`
|
||||
|
||||
Draws an unfilled antialiased circle on the given surface.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x: x coordinate of the center of the circle
|
||||
:param int y: y coordinate of the center of the circle
|
||||
:param int r: radius of the circle
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.aacircle ##
|
||||
|
||||
.. function:: filled_circle
|
||||
|
||||
| :sl:`draw a filled circle`
|
||||
| :sg:`filled_circle(surface, x, y, r, color, /) -> None`
|
||||
|
||||
Draws a filled circle on the given surface. For an unfilled circle use
|
||||
:meth:`circle`.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x: x coordinate of the center of the circle
|
||||
:param int y: y coordinate of the center of the circle
|
||||
:param int r: radius of the circle
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.filled_circle ##
|
||||
|
||||
.. function:: ellipse
|
||||
|
||||
| :sl:`draw an ellipse`
|
||||
| :sg:`ellipse(surface, x, y, rx, ry, color, /) -> None`
|
||||
|
||||
Draws an unfilled ellipse on the given surface. For a filled ellipse use
|
||||
:meth:`filled_ellipse`.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x: x coordinate of the center of the ellipse
|
||||
:param int y: y coordinate of the center of the ellipse
|
||||
:param int rx: horizontal radius of the ellipse
|
||||
:param int ry: vertical radius of the ellipse
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.ellipse ##
|
||||
|
||||
.. function:: aaellipse
|
||||
|
||||
| :sl:`draw an antialiased ellipse`
|
||||
| :sg:`aaellipse(surface, x, y, rx, ry, color, /) -> None`
|
||||
|
||||
Draws an unfilled antialiased ellipse on the given surface.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x: x coordinate of the center of the ellipse
|
||||
:param int y: y coordinate of the center of the ellipse
|
||||
:param int rx: horizontal radius of the ellipse
|
||||
:param int ry: vertical radius of the ellipse
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.aaellipse ##
|
||||
|
||||
.. function:: filled_ellipse
|
||||
|
||||
| :sl:`draw a filled ellipse`
|
||||
| :sg:`filled_ellipse(surface, x, y, rx, ry, color, /) -> None`
|
||||
|
||||
Draws a filled ellipse on the given surface. For an unfilled ellipse use
|
||||
:meth:`ellipse`.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x: x coordinate of the center of the ellipse
|
||||
:param int y: y coordinate of the center of the ellipse
|
||||
:param int rx: horizontal radius of the ellipse
|
||||
:param int ry: vertical radius of the ellipse
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.filled_ellipse ##
|
||||
|
||||
.. function:: arc
|
||||
|
||||
| :sl:`draw an arc`
|
||||
| :sg:`arc(surface, x, y, r, start_angle, stop_angle, color, /) -> None`
|
||||
|
||||
Draws an arc on the given surface. For an arc with its endpoints connected
|
||||
to its center use :meth:`pie`.
|
||||
|
||||
The two angle arguments are given in degrees and indicate the start and stop
|
||||
positions of the arc. The arc is drawn in a clockwise direction from the
|
||||
``start_angle`` to the ``stop_angle``. If ``start_angle == stop_angle``,
|
||||
nothing will be drawn
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x: x coordinate of the center of the arc
|
||||
:param int y: y coordinate of the center of the arc
|
||||
:param int r: radius of the arc
|
||||
:param int start_angle: start angle in degrees
|
||||
:param int stop_angle: stop angle in degrees
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. note::
|
||||
This function uses *degrees* while the :func:`pygame.draw.arc` function
|
||||
uses *radians*.
|
||||
|
||||
.. ## pygame.gfxdraw.arc ##
|
||||
|
||||
.. function:: pie
|
||||
|
||||
| :sl:`draw a pie`
|
||||
| :sg:`pie(surface, x, y, r, start_angle, stop_angle, color, /) -> None`
|
||||
|
||||
Draws an unfilled pie on the given surface. A pie is an :meth:`arc` with its
|
||||
endpoints connected to its center.
|
||||
|
||||
The two angle arguments are given in degrees and indicate the start and stop
|
||||
positions of the pie. The pie is drawn in a clockwise direction from the
|
||||
``start_angle`` to the ``stop_angle``. If ``start_angle == stop_angle``,
|
||||
a straight line will be drawn from the center position at the given angle,
|
||||
to a length of the radius.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x: x coordinate of the center of the pie
|
||||
:param int y: y coordinate of the center of the pie
|
||||
:param int r: radius of the pie
|
||||
:param int start_angle: start angle in degrees
|
||||
:param int stop_angle: stop angle in degrees
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.pie ##
|
||||
|
||||
.. function:: trigon
|
||||
|
||||
| :sl:`draw a trigon/triangle`
|
||||
| :sg:`trigon(surface, x1, y1, x2, y2, x3, y3, color, /) -> None`
|
||||
|
||||
Draws an unfilled trigon (triangle) on the given surface. For a filled
|
||||
trigon use :meth:`filled_trigon`.
|
||||
|
||||
A trigon can also be drawn using :meth:`polygon` e.g.
|
||||
``polygon(surface, ((x1, y1), (x2, y2), (x3, y3)), color)``
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x1: x coordinate of the first corner of the trigon
|
||||
:param int y1: y coordinate of the first corner of the trigon
|
||||
:param int x2: x coordinate of the second corner of the trigon
|
||||
:param int y2: y coordinate of the second corner of the trigon
|
||||
:param int x3: x coordinate of the third corner of the trigon
|
||||
:param int y3: y coordinate of the third corner of the trigon
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.trigon ##
|
||||
|
||||
.. function:: aatrigon
|
||||
|
||||
| :sl:`draw an antialiased trigon/triangle`
|
||||
| :sg:`aatrigon(surface, x1, y1, x2, y2, x3, y3, color, /) -> None`
|
||||
|
||||
Draws an unfilled antialiased trigon (triangle) on the given surface.
|
||||
|
||||
An aatrigon can also be drawn using :meth:`aapolygon` e.g.
|
||||
``aapolygon(surface, ((x1, y1), (x2, y2), (x3, y3)), color)``
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x1: x coordinate of the first corner of the trigon
|
||||
:param int y1: y coordinate of the first corner of the trigon
|
||||
:param int x2: x coordinate of the second corner of the trigon
|
||||
:param int y2: y coordinate of the second corner of the trigon
|
||||
:param int x3: x coordinate of the third corner of the trigon
|
||||
:param int y3: y coordinate of the third corner of the trigon
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.aatrigon ##
|
||||
|
||||
.. function:: filled_trigon
|
||||
|
||||
| :sl:`draw a filled trigon/triangle`
|
||||
| :sg:`filled_trigon(surface, x1, y1, x2, y2, x3, y3, color, /) -> None`
|
||||
|
||||
Draws a filled trigon (triangle) on the given surface. For an unfilled
|
||||
trigon use :meth:`trigon`.
|
||||
|
||||
A filled_trigon can also be drawn using :meth:`filled_polygon` e.g.
|
||||
``filled_polygon(surface, ((x1, y1), (x2, y2), (x3, y3)), color)``
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param int x1: x coordinate of the first corner of the trigon
|
||||
:param int y1: y coordinate of the first corner of the trigon
|
||||
:param int x2: x coordinate of the second corner of the trigon
|
||||
:param int y2: y coordinate of the second corner of the trigon
|
||||
:param int x3: x coordinate of the third corner of the trigon
|
||||
:param int y3: y coordinate of the third corner of the trigon
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
.. ## pygame.gfxdraw.filled_trigon ##
|
||||
|
||||
.. function:: polygon
|
||||
|
||||
| :sl:`draw a polygon`
|
||||
| :sg:`polygon(surface, points, color, /) -> None`
|
||||
|
||||
Draws an unfilled polygon on the given surface. For a filled polygon use
|
||||
:meth:`filled_polygon`.
|
||||
|
||||
The adjacent points in the ``points`` argument, as well as the first
|
||||
and last points, will be connected by line segments.
|
||||
e.g. For the points ``[(x1, y1), (x2, y2), (x3, y3)]`` a line segment will
|
||||
be drawn from ``(x1, y1)`` to ``(x2, y2)``, from ``(x2, y2)`` to
|
||||
``(x3, y3)``, and from ``(x3, y3)`` to ``(x1, y1)``.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param points: a sequence of 3 or more (x, y) coordinates, where each
|
||||
point in the sequence must be a
|
||||
tuple/list/:class:`pygame.math.Vector2` of 2 ints/floats (float values
|
||||
will be truncated)
|
||||
:type points: tuple(point) or list(point)
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
:raises ValueError: if ``len(points) < 3`` (must have at least 3 points)
|
||||
:raises IndexError: if ``len(point) < 2`` (each point must have
|
||||
at least 2 items)
|
||||
|
||||
.. ## pygame.gfxdraw.polygon ##
|
||||
|
||||
.. function:: aapolygon
|
||||
|
||||
| :sl:`draw an antialiased polygon`
|
||||
| :sg:`aapolygon(surface, points, color, /) -> None`
|
||||
|
||||
Draws an unfilled antialiased polygon on the given surface.
|
||||
|
||||
The adjacent points in the ``points`` argument, as well as the first
|
||||
and last points, will be connected by line segments.
|
||||
e.g. For the points ``[(x1, y1), (x2, y2), (x3, y3)]`` a line segment will
|
||||
be drawn from ``(x1, y1)`` to ``(x2, y2)``, from ``(x2, y2)`` to
|
||||
``(x3, y3)``, and from ``(x3, y3)`` to ``(x1, y1)``.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param points: a sequence of 3 or more (x, y) coordinates, where each
|
||||
point in the sequence must be a
|
||||
tuple/list/:class:`pygame.math.Vector2` of 2 ints/floats (float values
|
||||
will be truncated)
|
||||
:type points: tuple(point) or list(point)
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
:raises ValueError: if ``len(points) < 3`` (must have at least 3 points)
|
||||
:raises IndexError: if ``len(point) < 2`` (each point must have
|
||||
at least 2 items)
|
||||
|
||||
.. ## pygame.gfxdraw.aapolygon ##
|
||||
|
||||
.. function:: filled_polygon
|
||||
|
||||
| :sl:`draw a filled polygon`
|
||||
| :sg:`filled_polygon(surface, points, color, /) -> None`
|
||||
|
||||
Draws a filled polygon on the given surface. For an unfilled polygon use
|
||||
:meth:`polygon`.
|
||||
|
||||
The adjacent points in the ``points`` argument, as well as the first
|
||||
and last points, will be connected by line segments.
|
||||
e.g. For the points ``[(x1, y1), (x2, y2), (x3, y3)]`` a line segment will
|
||||
be drawn from ``(x1, y1)`` to ``(x2, y2)``, from ``(x2, y2)`` to
|
||||
``(x3, y3)``, and from ``(x3, y3)`` to ``(x1, y1)``.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param points: a sequence of 3 or more (x, y) coordinates, where each
|
||||
point in the sequence must be a
|
||||
tuple/list/:class:`pygame.math.Vector2` of 2 ints/floats (float values
|
||||
will be truncated)`
|
||||
:type points: tuple(point) or list(point)
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
:raises ValueError: if ``len(points) < 3`` (must have at least 3 points)
|
||||
:raises IndexError: if ``len(point) < 2`` (each point must have
|
||||
at least 2 items)
|
||||
|
||||
.. ## pygame.gfxdraw.filled_polygon ##
|
||||
|
||||
.. function:: textured_polygon
|
||||
|
||||
| :sl:`draw a textured polygon`
|
||||
| :sg:`textured_polygon(surface, points, texture, tx, ty, /) -> None`
|
||||
|
||||
Draws a textured polygon on the given surface. For better performance, the
|
||||
surface and the texture should have the same format.
|
||||
|
||||
A per-pixel alpha texture blit to a per-pixel alpha surface will differ from
|
||||
a :func:`pygame.Surface.blit` blit. Also, a per-pixel alpha texture cannot be
|
||||
used with an 8-bit per pixel destination.
|
||||
|
||||
The adjacent points in the ``points`` argument, as well as the first
|
||||
and last points, will be connected by line segments.
|
||||
e.g. For the points ``[(x1, y1), (x2, y2), (x3, y3)]`` a line segment will
|
||||
be drawn from ``(x1, y1)`` to ``(x2, y2)``, from ``(x2, y2)`` to
|
||||
``(x3, y3)``, and from ``(x3, y3)`` to ``(x1, y1)``.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param points: a sequence of 3 or more (x, y) coordinates, where each
|
||||
point in the sequence must be a
|
||||
tuple/list/:class:`pygame.math.Vector2` of 2 ints/floats (float values
|
||||
will be truncated)
|
||||
:type points: tuple(point) or list(point)
|
||||
:param Surface texture: texture to draw on the polygon
|
||||
:param int tx: x offset of the texture
|
||||
:param int ty: y offset of the texture
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
:raises ValueError: if ``len(points) < 3`` (must have at least 3 points)
|
||||
:raises IndexError: if ``len(point) < 2`` (each point must have
|
||||
at least 2 items)
|
||||
|
||||
.. ## pygame.gfxdraw.textured_polygon ##
|
||||
|
||||
.. function:: bezier
|
||||
|
||||
| :sl:`draw a Bezier curve`
|
||||
| :sg:`bezier(surface, points, steps, color, /) -> None`
|
||||
|
||||
Draws a Bézier curve on the given surface.
|
||||
|
||||
:param Surface surface: surface to draw on
|
||||
:param points: a sequence of 3 or more (x, y) coordinates used to form a
|
||||
curve, where each point in the sequence must be a
|
||||
tuple/list/:class:`pygame.math.Vector2` of 2 ints/floats (float values
|
||||
will be truncated)
|
||||
:type points: tuple(point) or list(point)
|
||||
:param int steps: number of steps for the interpolation, the minimum is 2
|
||||
:param color: color to draw with, the alpha value is optional if using a
|
||||
tuple ``(RGB[A])``
|
||||
:type color: Color or tuple(int, int, int, [int])
|
||||
|
||||
:returns: ``None``
|
||||
:rtype: NoneType
|
||||
|
||||
:raises ValueError: if ``steps < 2``
|
||||
:raises ValueError: if ``len(points) < 3`` (must have at least 3 points)
|
||||
:raises IndexError: if ``len(point) < 2`` (each point must have
|
||||
at least 2 items)
|
||||
|
||||
.. note:: This function supports up to around 150-200 points before the algorithm
|
||||
breaks down.
|
||||
|
||||
.. ## pygame.gfxdraw.bezier ##
|
||||
|
||||
.. ## pygame.gfxdraw ##
|
||||
@@ -0,0 +1,7 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.image`
|
||||
===================
|
||||
|
||||
.. autopgmodule:: pygame.image
|
||||
:members:
|
||||
@@ -0,0 +1,712 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.joystick`
|
||||
======================
|
||||
|
||||
.. module:: pygame.joystick
|
||||
:synopsis: Pygame module for interacting with joysticks, gamepads, and trackballs.
|
||||
|
||||
| :sl:`Pygame module for interacting with joysticks, gamepads, and trackballs.`
|
||||
|
||||
The joystick module manages the joystick devices on a computer.
|
||||
Joystick devices include trackballs and video-game-style
|
||||
gamepads, and the module allows the use of multiple buttons and "hats".
|
||||
Computers may manage multiple joysticks at a time.
|
||||
|
||||
Each instance of the Joystick class represents one gaming device plugged
|
||||
into the computer. If a gaming pad has multiple joysticks on it, then the
|
||||
joystick object can actually represent multiple joysticks on that single
|
||||
game device.
|
||||
|
||||
For a quick way to initialise the joystick module and get a list of Joystick instances
|
||||
use the following code::
|
||||
|
||||
pygame.joystick.init()
|
||||
joysticks = [pygame.joystick.Joystick(x) for x in range(pygame.joystick.get_count())]
|
||||
|
||||
The following event types will be generated by the joysticks ::
|
||||
|
||||
JOYAXISMOTION JOYBALLMOTION JOYBUTTONDOWN JOYBUTTONUP JOYHATMOTION
|
||||
|
||||
And in pygame 2, which supports hotplugging::
|
||||
|
||||
JOYDEVICEADDED JOYDEVICEREMOVED
|
||||
|
||||
Note that in pygame 2, joysticks events use a unique "instance ID". The device index
|
||||
passed in the constructor to a Joystick object is not unique after devices have
|
||||
been added and removed. You must call :meth:`Joystick.get_instance_id()` to find
|
||||
the instance ID that was assigned to a Joystick on opening.
|
||||
|
||||
The event queue needs to be pumped frequently for some of the methods to work.
|
||||
So call one of pygame.event.get, pygame.event.wait, or pygame.event.pump regularly.
|
||||
|
||||
To be able to get joystick events and update the joystick objects while the window
|
||||
is not in focus, you may set the ``SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS`` environment
|
||||
variable. See :ref:`environment variables <environment-variables>` for more details.
|
||||
|
||||
|
||||
.. function:: init
|
||||
|
||||
| :sl:`Initialize the joystick module.`
|
||||
| :sg:`init() -> None`
|
||||
|
||||
This function is called automatically by ``pygame.init()``.
|
||||
|
||||
It initializes the joystick module. The module must be initialized before any
|
||||
other functions will work.
|
||||
|
||||
It is safe to call this function more than once.
|
||||
|
||||
.. ## pygame.joystick.init ##
|
||||
|
||||
.. function:: quit
|
||||
|
||||
| :sl:`Uninitialize the joystick module.`
|
||||
| :sg:`quit() -> None`
|
||||
|
||||
Uninitialize the joystick module. After you call this any existing joystick
|
||||
objects will no longer work.
|
||||
|
||||
It is safe to call this function more than once.
|
||||
|
||||
.. ## pygame.joystick.quit ##
|
||||
|
||||
.. function:: get_init
|
||||
|
||||
| :sl:`Returns True if the joystick module is initialized.`
|
||||
| :sg:`get_init() -> bool`
|
||||
|
||||
Test if the ``pygame.joystick.init()`` function has been called.
|
||||
|
||||
.. ## pygame.joystick.get_init ##
|
||||
|
||||
.. function:: get_count
|
||||
|
||||
| :sl:`Returns the number of joysticks.`
|
||||
| :sg:`get_count() -> count`
|
||||
|
||||
Return the number of joystick devices on the system. The count will be ``0``
|
||||
if there are no joysticks on the system.
|
||||
|
||||
When you create Joystick objects using ``Joystick(id)``, you pass an integer
|
||||
that must be lower than this count.
|
||||
|
||||
.. ## pygame.joystick.get_count ##
|
||||
|
||||
.. class:: Joystick
|
||||
|
||||
| :sl:`Create a new Joystick object.`
|
||||
| :sg:`Joystick(id, /) -> Joystick`
|
||||
|
||||
Create a new joystick to access a physical device. The id argument must be a
|
||||
value from ``0`` to ``pygame.joystick.get_count() - 1``.
|
||||
|
||||
Joysticks are initialised on creation and are shut down when deallocated.
|
||||
Once the device is initialized the pygame event queue will start receiving
|
||||
events about its input.
|
||||
|
||||
.. versionchangedold:: 2.0.0 Joystick objects are now opened immediately on creation.
|
||||
|
||||
.. versionchanged:: 2.1.4 This class is also available through the ``pygame.Joystick``
|
||||
alias.
|
||||
|
||||
.. method:: init
|
||||
|
||||
| :sl:`initialize the Joystick`
|
||||
| :sg:`init() -> None`
|
||||
|
||||
Initialize the joystick, if it has been closed. It is safe to call this
|
||||
even if the joystick is already initialized.
|
||||
|
||||
.. deprecatedold:: 2.0.0
|
||||
|
||||
In future it will not be possible to reinitialise a closed Joystick
|
||||
object.
|
||||
|
||||
.. ## Joystick.init ##
|
||||
|
||||
.. method:: quit
|
||||
|
||||
| :sl:`uninitialize the Joystick`
|
||||
| :sg:`quit() -> None`
|
||||
|
||||
Close a Joystick object. After this the pygame event queue will no longer
|
||||
receive events from the device.
|
||||
|
||||
It is safe to call this more than once.
|
||||
|
||||
.. ## Joystick.quit ##
|
||||
|
||||
.. method:: get_init
|
||||
|
||||
| :sl:`check if the Joystick is initialized`
|
||||
| :sg:`get_init() -> bool`
|
||||
|
||||
Return True if the Joystick object is currently initialised.
|
||||
|
||||
.. ## Joystick.get_init ##
|
||||
|
||||
.. method:: get_id
|
||||
|
||||
| :sl:`get the device index (deprecated)`
|
||||
| :sg:`get_id() -> int`
|
||||
|
||||
Returns the original device index for this device. This is the same
|
||||
value that was passed to the ``Joystick()`` constructor. This method can
|
||||
safely be called while the Joystick is not initialized.
|
||||
|
||||
.. deprecatedold:: 2.0.0
|
||||
|
||||
The original device index is not useful in pygame 2. Use
|
||||
:meth:`.get_instance_id` instead.
|
||||
|
||||
.. method:: get_instance_id() -> int
|
||||
|
||||
| :sl:`get the joystick instance id`
|
||||
| :sg:`get_instance_id() -> int`
|
||||
|
||||
Get the joystick instance ID. This matches the ``instance_id`` field
|
||||
that is given in joystick events.
|
||||
|
||||
.. versionaddedold:: 2.0.0dev11
|
||||
|
||||
.. method:: get_guid() -> str
|
||||
|
||||
| :sl:`get the joystick GUID`
|
||||
| :sg:`get_guid() -> str`
|
||||
|
||||
Get the GUID string. This identifies the exact hardware of the joystick
|
||||
device.
|
||||
|
||||
.. versionaddedold:: 2.0.0dev11
|
||||
|
||||
.. method:: get_power_level() -> str
|
||||
|
||||
| :sl:`get the approximate power status of the device`
|
||||
| :sg:`get_power_level() -> str`
|
||||
|
||||
Get a string giving the power status of the device.
|
||||
|
||||
One of: ``empty``, ``low``, ``medium``, ``full``, ``wired``, ``max``, or
|
||||
``unknown``.
|
||||
|
||||
.. versionaddedold:: 2.0.0dev11
|
||||
|
||||
.. ## Joystick.get_id ##
|
||||
|
||||
.. method:: get_name
|
||||
|
||||
| :sl:`get the Joystick system name`
|
||||
| :sg:`get_name() -> string`
|
||||
|
||||
Returns the system name for this joystick device. It is unknown what name
|
||||
the system will give to the Joystick, but it should be a unique name that
|
||||
identifies the device. This method can safely be called while the
|
||||
Joystick is not initialized.
|
||||
|
||||
.. ## Joystick.get_name ##
|
||||
|
||||
.. method:: get_numaxes
|
||||
|
||||
| :sl:`get the number of axes on a Joystick`
|
||||
| :sg:`get_numaxes() -> int`
|
||||
|
||||
Returns the number of input axes are on a Joystick. There will usually be
|
||||
two for the position. Controls like rudders and throttles are treated as
|
||||
additional axes.
|
||||
|
||||
The ``pygame.JOYAXISMOTION`` events will be in the range from ``-1.0``
|
||||
to ``1.0``. A value of ``0.0`` means the axis is centered. Gamepad devices
|
||||
will usually be ``-1``, ``0``, or ``1`` with no values in between. Older
|
||||
analog joystick axes will not always use the full ``-1`` to ``1`` range,
|
||||
and the centered value will be some area around ``0``.
|
||||
|
||||
Analog joysticks usually have a bit of noise in their axis, which will
|
||||
generate a lot of rapid small motion events.
|
||||
|
||||
.. ## Joystick.get_numaxes ##
|
||||
|
||||
.. method:: get_axis
|
||||
|
||||
| :sl:`get the current position of an axis`
|
||||
| :sg:`get_axis(axis_number, /) -> float`
|
||||
|
||||
Returns the current position of a joystick axis. The value will range
|
||||
from ``-1`` to ``1`` with a value of ``0`` being centered. You may want
|
||||
to take into account some tolerance to handle jitter, and joystick drift
|
||||
may keep the joystick from centering at ``0`` or using the full range of
|
||||
position values.
|
||||
|
||||
The axis number must be an integer from ``0`` to ``get_numaxes() - 1``.
|
||||
|
||||
When using gamepads both the control sticks and the analog triggers are
|
||||
usually reported as axes.
|
||||
|
||||
.. ## Joystick.get_axis ##
|
||||
|
||||
.. method:: get_numballs
|
||||
|
||||
| :sl:`get the number of trackballs on a Joystick`
|
||||
| :sg:`get_numballs() -> int`
|
||||
|
||||
Returns the number of trackball devices on a Joystick. These devices work
|
||||
similar to a mouse but they have no absolute position; they only have
|
||||
relative amounts of movement.
|
||||
|
||||
The ``pygame.JOYBALLMOTION`` event will be sent when the trackball is
|
||||
rolled. It will report the amount of movement on the trackball.
|
||||
|
||||
.. ## Joystick.get_numballs ##
|
||||
|
||||
.. method:: get_ball
|
||||
|
||||
| :sl:`get the relative position of a trackball`
|
||||
| :sg:`get_ball(ball_number, /) -> x, y`
|
||||
|
||||
Returns the relative movement of a joystick button. The value is a ``x, y``
|
||||
pair holding the relative movement since the last call to get_ball.
|
||||
|
||||
The ball number must be an integer from ``0`` to ``get_numballs() - 1``.
|
||||
|
||||
.. ## Joystick.get_ball ##
|
||||
|
||||
.. method:: get_numbuttons
|
||||
|
||||
| :sl:`get the number of buttons on a Joystick`
|
||||
| :sg:`get_numbuttons() -> int`
|
||||
|
||||
Returns the number of pushable buttons on the joystick. These buttons
|
||||
have a boolean (on or off) state.
|
||||
|
||||
Buttons generate a ``pygame.JOYBUTTONDOWN`` and ``pygame.JOYBUTTONUP``
|
||||
event when they are pressed and released.
|
||||
|
||||
.. ## Joystick.get_numbuttons ##
|
||||
|
||||
.. method:: get_button
|
||||
|
||||
| :sl:`get the current button state`
|
||||
| :sg:`get_button(button, /) -> bool`
|
||||
|
||||
Returns the current state of a joystick button.
|
||||
|
||||
.. ## Joystick.get_button ##
|
||||
|
||||
.. method:: get_numhats
|
||||
|
||||
| :sl:`get the number of hat controls on a Joystick`
|
||||
| :sg:`get_numhats() -> int`
|
||||
|
||||
Returns the number of joystick hats on a Joystick. Hat devices are like
|
||||
miniature digital joysticks on a joystick. Each hat has two axes of
|
||||
input.
|
||||
|
||||
The ``pygame.JOYHATMOTION`` event is generated when the hat changes
|
||||
position. The ``position`` attribute for the event contains a pair of
|
||||
values that are either ``-1``, ``0``, or ``1``. A position of ``(0, 0)``
|
||||
means the hat is centered.
|
||||
|
||||
.. ## Joystick.get_numhats ##
|
||||
|
||||
.. method:: get_hat
|
||||
|
||||
| :sl:`get the position of a joystick hat`
|
||||
| :sg:`get_hat(hat_number, /) -> x, y`
|
||||
|
||||
Returns the current position of a position hat. The position is given as
|
||||
two values representing the ``x`` and ``y`` position for the hat. ``(0, 0)``
|
||||
means centered. A value of ``-1`` means left/down and a value of ``1`` means
|
||||
right/up: so ``(-1, 0)`` means left; ``(1, 0)`` means right; ``(0, 1)`` means
|
||||
up; ``(1, 1)`` means upper-right; etc.
|
||||
|
||||
This value is digital, ``i.e.``, each coordinate can be ``-1``, ``0`` or ``1``
|
||||
but never in-between.
|
||||
|
||||
The hat number must be between ``0`` and ``get_numhats() - 1``.
|
||||
|
||||
.. ## Joystick.get_hat ##
|
||||
|
||||
.. method:: rumble
|
||||
|
||||
| :sl:`Start a rumbling effect`
|
||||
| :sg:`rumble(low_frequency, high_frequency, duration) -> bool`
|
||||
|
||||
Start a rumble effect on the joystick, with the specified strength ranging
|
||||
from 0 to 1. Duration is length of the effect, in ms. Setting the duration
|
||||
to 0 will play the effect until another one overwrites it or
|
||||
:meth:`Joystick.stop_rumble` is called. If an effect is already
|
||||
playing, then it will be overwritten.
|
||||
|
||||
Returns True if the rumble was played successfully or False if the
|
||||
joystick does not support it.
|
||||
|
||||
.. versionaddedold:: 2.0.2
|
||||
|
||||
.. ## Joystick.rumble ##
|
||||
|
||||
.. method:: stop_rumble
|
||||
|
||||
| :sl:`Stop any rumble effect playing`
|
||||
| :sg:`stop_rumble() -> None`
|
||||
|
||||
Stops any rumble effect playing on the joystick. See
|
||||
:meth:`Joystick.rumble` for more information.
|
||||
|
||||
.. versionaddedold:: 2.0.2
|
||||
|
||||
.. ## Joystick.stop_rumble ##
|
||||
|
||||
.. method:: set_led
|
||||
|
||||
| :sl:`Set the LED color of the joystick`
|
||||
| :sg:`set_led(color_arg) -> bool`
|
||||
|
||||
Set the color of the LED on the joystick. The argument is a
|
||||
``pygame.Color``-compatible value (alpha being ignored). The
|
||||
joystick's LED, if it has one, will be set to the input color.
|
||||
If the joystick does not have an addressable LED, then this
|
||||
method will do nothing and return False. Returns True if the
|
||||
LED was set successfully.
|
||||
|
||||
.. versionadded:: 2.5.6
|
||||
|
||||
.. ## Joystick.set_led ##
|
||||
|
||||
.. ## pygame.joystick.Joystick ##
|
||||
|
||||
.. ## pygame.joystick ##
|
||||
|
||||
.. figure:: code_examples/joystick_calls.png
|
||||
:scale: 100 %
|
||||
:alt: joystick module example
|
||||
|
||||
Example code for joystick module.
|
||||
|
||||
.. literalinclude:: ../../../examples/joystick.py
|
||||
|
||||
.. _controller-mappings:
|
||||
|
||||
|
||||
Common Controller Axis Mappings
|
||||
===============================
|
||||
|
||||
Controller mappings are drawn from the underlying SDL library which pygame uses and they differ
|
||||
between pygame 1 and pygame 2. Below are a couple of mappings for three popular controllers.
|
||||
|
||||
Axis and hat mappings are listed from -1 to +1.
|
||||
|
||||
|
||||
Nintendo Switch Left Joy-Con (pygame 2.x)
|
||||
*****************************************
|
||||
|
||||
The Nintendo Switch Left Joy-Con has 4 axes, 11 buttons, and 0 hats. The values for the 4 axes never change.
|
||||
The controller is recognized as "Wireless Gamepad".
|
||||
After SDL 2.24.0, The controller is recognized as "Nintendo Switch Joy-Con (L)".
|
||||
|
||||
|
||||
* **Buttons**::
|
||||
|
||||
After SDL 2.24.0 Before SDL 2.24.0
|
||||
D-pad Up Button 2 Button 3
|
||||
D-pad Down Button 1 Button 0
|
||||
D-pad Left Button 3 Button 2
|
||||
D-pad Right Button 0 Button 1
|
||||
SL Button 9 Button 4
|
||||
SR Button 10 Button 5
|
||||
- Button 6 Button 8
|
||||
Stick In Button 7 Button 10
|
||||
Capture Button 5 Button 13
|
||||
L Button 17 Button 14
|
||||
ZL Button 19 Button 15
|
||||
|
||||
Reference : D-pad Up points toward SL and SR buttons.
|
||||
|
||||
* **Hat/JoyStick**::
|
||||
|
||||
Down -> Up - Axis 1 Axis Y
|
||||
Left -> Right - Axis 0 Axis X
|
||||
|
||||
|
||||
Nintendo Switch Right Joy-Con (pygame 2.x)
|
||||
******************************************
|
||||
|
||||
The Nintendo Switch Right Joy-Con has 4 axes, 11 buttons, and 0 hats. The values for the 4 axes never change.
|
||||
The controller is recognized as "Wireless Gamepad".
|
||||
After SDL 2.24.0, The controller is recognized as "Nintendo Switch Joy-Con (R)".
|
||||
|
||||
* **Buttons**::
|
||||
|
||||
After SDL 2.24.0 Before SDL 2.24.0
|
||||
A Button Button 1 Button 0
|
||||
B Button Button 3 Button 2
|
||||
X Button Button 0 Button 1
|
||||
Y Button Button 2 Button 3
|
||||
SL Button 9 Button 4
|
||||
SR Button 10 Button 5
|
||||
+ Button 6 Button 9
|
||||
Stick In Button 7 Button 11
|
||||
Home Button 5 Button 12
|
||||
R Button 16 Button 14
|
||||
ZR Button 18 Button 15
|
||||
|
||||
* **Hat/JoyStick**::
|
||||
|
||||
Down -> Up - Axis 1 Axis Y
|
||||
Left -> Right - Axis 0 Axis X
|
||||
|
||||
Nintendo Switch Left/Right Joy-Con (after SDL **2.24.0**)
|
||||
*********************************************************
|
||||
This device is created, if Nintendo Switch Joy-con Left and Nintendo Switch Joy-con Right are connected (these two devices are removed).
|
||||
The Nintendo Switch Left/Right Joy-Con has 6 axes, 20 buttons, and 0 hats. The values for the 6 axes never change.
|
||||
The controller is recognized as "Nintendo Switch Joy-Con (L/R)".
|
||||
|
||||
* **Left Stick**::
|
||||
|
||||
Left -> Right - Axis 0
|
||||
Up -> Down - Axis 1
|
||||
|
||||
* **Right Stick**::
|
||||
|
||||
Left -> Right - Axis 2
|
||||
Up -> Down - Axis 3
|
||||
|
||||
* **Buttons**::
|
||||
|
||||
A Button - Button 0
|
||||
B Button - Button 1
|
||||
X Button - Button 2
|
||||
Y Button - Button 3
|
||||
- Button - Button 4
|
||||
Home Button - Button 5
|
||||
+ Button - Button 6
|
||||
ZL - Button ? Missing
|
||||
ZR - Button ? Missing
|
||||
L. Stick In - Button 9
|
||||
R. Stick In - Button 10
|
||||
D-pad Up - Button 11
|
||||
D-pad Down - Button 12
|
||||
D-pad Left - Button 13
|
||||
D-pad Right - Button 14
|
||||
Capture Button - Button 15
|
||||
Right SR - Button 16
|
||||
Left SL - Button 17
|
||||
Right SL - Button 18
|
||||
Left SR - Button 19
|
||||
|
||||
Nintendo Switch Pro Controller (pygame 2.x)
|
||||
*******************************************
|
||||
|
||||
The Nintendo Switch Pro Controller has 6 axes, 16 buttons, and 0 hats.
|
||||
The controller is recognized as "Nintendo Switch Pro Controller".
|
||||
|
||||
|
||||
* **Left Stick**::
|
||||
|
||||
Left -> Right - Axis 0
|
||||
Up -> Down - Axis 1
|
||||
|
||||
* **Right Stick**::
|
||||
|
||||
Left -> Right - Axis 2
|
||||
Up -> Down - Axis 3
|
||||
|
||||
* **Left Trigger**::
|
||||
|
||||
Out -> In - Axis 4
|
||||
|
||||
* **Right Trigger**::
|
||||
|
||||
Out -> In - Axis 5
|
||||
|
||||
* **Buttons**::
|
||||
|
||||
A Button - Button 0
|
||||
B Button - Button 1
|
||||
X Button - Button 2
|
||||
Y Button - Button 3
|
||||
- Button - Button 4
|
||||
Home Button - Button 5
|
||||
+ Button - Button 6
|
||||
L. Stick In - Button 7
|
||||
R. Stick In - Button 8
|
||||
Left Bumper - Button 9
|
||||
Right Bumper - Button 10
|
||||
D-pad Up - Button 11
|
||||
D-pad Down - Button 12
|
||||
D-pad Left - Button 13
|
||||
D-pad Right - Button 14
|
||||
Capture Button - Button 15
|
||||
|
||||
|
||||
XBox 360 Controller (pygame 2.x)
|
||||
********************************
|
||||
|
||||
The Xbox 360 controller mapping has 6 axes, 11 buttons and 1 hat.
|
||||
The controller is recognized as "Xbox 360 Controller".
|
||||
|
||||
* **Left Stick**::
|
||||
|
||||
Left -> Right - Axis 0
|
||||
Up -> Down - Axis 1
|
||||
|
||||
* **Right Stick**::
|
||||
|
||||
Left -> Right - Axis 3
|
||||
Up -> Down - Axis 4
|
||||
|
||||
* **Left Trigger**::
|
||||
|
||||
Out -> In - Axis 2
|
||||
|
||||
* **Right Trigger**::
|
||||
|
||||
Out -> In - Axis 5
|
||||
|
||||
* **Buttons**::
|
||||
|
||||
A Button - Button 0
|
||||
B Button - Button 1
|
||||
X Button - Button 2
|
||||
Y Button - Button 3
|
||||
Left Bumper - Button 4
|
||||
Right Bumper - Button 5
|
||||
Back Button - Button 6
|
||||
Start Button - Button 7
|
||||
L. Stick In - Button 8
|
||||
R. Stick In - Button 9
|
||||
Guide Button - Button 10
|
||||
|
||||
* **Hat/D-pad**::
|
||||
|
||||
Down -> Up - Y Axis
|
||||
Left -> Right - X Axis
|
||||
|
||||
|
||||
Playstation 4 Controller (pygame 2.x)
|
||||
*************************************
|
||||
|
||||
The PlayStation 4 controller mapping has 6 axes and 16 buttons.
|
||||
The controller is recognized as "PS4 Controller".
|
||||
|
||||
* **Left Stick**::
|
||||
|
||||
Left -> Right - Axis 0
|
||||
Up -> Down - Axis 1
|
||||
|
||||
* **Right Stick**::
|
||||
|
||||
Left -> Right - Axis 2
|
||||
Up -> Down - Axis 3
|
||||
|
||||
* **Left Trigger**::
|
||||
|
||||
Out -> In - Axis 4
|
||||
|
||||
* **Right Trigger**::
|
||||
|
||||
Out -> In - Axis 5
|
||||
|
||||
* **Buttons**::
|
||||
|
||||
Cross Button - Button 0
|
||||
Circle Button - Button 1
|
||||
Square Button - Button 2
|
||||
Triangle Button - Button 3
|
||||
Share Button - Button 4
|
||||
PS Button - Button 5
|
||||
Options Button - Button 6
|
||||
L. Stick In - Button 7
|
||||
R. Stick In - Button 8
|
||||
Left Bumper - Button 9
|
||||
Right Bumper - Button 10
|
||||
D-pad Up - Button 11
|
||||
D-pad Down - Button 12
|
||||
D-pad Left - Button 13
|
||||
D-pad Right - Button 14
|
||||
Touch Pad Click - Button 15
|
||||
|
||||
|
||||
XBox 360 Controller (pygame 1.x)
|
||||
********************************
|
||||
|
||||
The Xbox 360 controller mapping has 5 axes, 10 buttons, and 1 hat.
|
||||
The controller is recognized as "Controller (XBOX 360 For Windows)".
|
||||
|
||||
* **Left Stick**::
|
||||
|
||||
Left -> Right - Axis 0
|
||||
Up -> Down - Axis 1
|
||||
|
||||
* **Right Stick**::
|
||||
|
||||
Left -> Right - Axis 4
|
||||
Up -> Down - Axis 3
|
||||
|
||||
* **Left Trigger & Right Trigger**::
|
||||
|
||||
RT -> LT - Axis 2
|
||||
|
||||
* **Buttons**::
|
||||
|
||||
A Button - Button 0
|
||||
B Button - Button 1
|
||||
X Button - Button 2
|
||||
Y Button - Button 3
|
||||
Left Bumper - Button 4
|
||||
Right Bumper - Button 5
|
||||
Back Button - Button 6
|
||||
Start Button - Button 7
|
||||
L. Stick In - Button 8
|
||||
R. Stick In - Button 9
|
||||
|
||||
* **Hat/D-pad**::
|
||||
|
||||
Down -> Up - Y Axis
|
||||
Left -> Right - X Axis
|
||||
|
||||
|
||||
Playstation 4 Controller (pygame 1.x)
|
||||
*************************************
|
||||
|
||||
The PlayStation 4 controller mapping has 6 axes, 14 buttons, and 1 hat.
|
||||
The controller is recognized as "Wireless Controller".
|
||||
|
||||
* **Left Stick**::
|
||||
|
||||
Left -> Right - Axis 0
|
||||
Up -> Down - Axis 1
|
||||
|
||||
* **Right Stick**::
|
||||
|
||||
Left -> Right - Axis 2
|
||||
Up -> Down - Axis 3
|
||||
|
||||
* **Left Trigger**::
|
||||
|
||||
Out -> In - Axis 5
|
||||
|
||||
* **Right Trigger**::
|
||||
|
||||
Out -> In - Axis 4
|
||||
|
||||
* **Buttons**::
|
||||
|
||||
Cross Button - Button 0
|
||||
Circle Button - Button 1
|
||||
Square Button - Button 2
|
||||
Triangle Button - Button 3
|
||||
Left Bumper - Button 4
|
||||
Right Bumper - Button 5
|
||||
L. Trigger(Full)- Button 6
|
||||
R. Trigger(Full)- Button 7
|
||||
Share Button - Button 8
|
||||
Options Button - Button 9
|
||||
L. Stick In - Button 10
|
||||
R. Stick In - Button 11
|
||||
PS Button - Button 12
|
||||
Touch Pad Click - Button 13
|
||||
|
||||
* **Hat/D-pad**::
|
||||
|
||||
Down -> Up - Y Axis
|
||||
Left -> Right - X Axis
|
||||
@@ -0,0 +1,8 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.key`
|
||||
=================
|
||||
|
||||
.. autopgmodule:: pygame.key
|
||||
:members:
|
||||
:exclude-members: ScancodeWrapper
|
||||
@@ -0,0 +1,27 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.locals`
|
||||
====================
|
||||
|
||||
.. module:: pygame.locals
|
||||
:synopsis: pygame constants
|
||||
|
||||
| :sl:`pygame constants`
|
||||
|
||||
This module contains various constants used by pygame. Its contents are
|
||||
automatically placed in the pygame module namespace. However, an application
|
||||
can use ``pygame.locals`` to include only the pygame constants with a ``from
|
||||
pygame.locals import *``.
|
||||
|
||||
Detailed descriptions of the various constants can be found throughout the
|
||||
pygame-ce documentation. Here are the locations of some of them.
|
||||
|
||||
- The :mod:`pygame.display` module contains flags like ``FULLSCREEN`` used
|
||||
by :func:`pygame.display.set_mode`.
|
||||
- The :mod:`pygame.event` module contains the various event types.
|
||||
- The :mod:`pygame.key` module lists the keyboard constants and modifiers
|
||||
(``K_``\* and ``MOD_``\*) relating to the ``key`` and ``mod`` attributes of
|
||||
the ``KEYDOWN`` and ``KEYUP`` events.
|
||||
- The :mod:`pygame.time` module defines ``TIMER_RESOLUTION``.
|
||||
|
||||
.. ## pygame.locals ##
|
||||
@@ -0,0 +1,8 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.mask`
|
||||
==================
|
||||
|
||||
.. autopgmodule:: pygame.mask
|
||||
:members:
|
||||
:exclude-members: MaskType
|
||||
@@ -0,0 +1,484 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.midi`
|
||||
==================
|
||||
|
||||
.. module:: pygame.midi
|
||||
:synopsis: pygame module for interacting with midi input and output.
|
||||
|
||||
| :sl:`pygame module for interacting with midi input and output.`
|
||||
|
||||
.. versionaddedold:: 1.9.0
|
||||
|
||||
The midi module can send output to midi devices and get input from midi
|
||||
devices. It can also list midi devices on the system.
|
||||
|
||||
The midi module supports real and virtual midi devices.
|
||||
|
||||
It uses the portmidi library. Is portable to which ever platforms portmidi
|
||||
supports (currently Windows, Mac OS X, and Linux).
|
||||
|
||||
This uses pyportmidi for now, but may use its own bindings at some point in the
|
||||
future. The pyportmidi bindings are included with pygame.
|
||||
|
||||
|
|
||||
|
||||
.. versionaddedold:: 2.0.0
|
||||
|
||||
These are pygame events (:mod:`pygame.event`) reserved for midi use. The
|
||||
``MIDIIN`` event is used by :func:`pygame.midi.midis2events` when converting
|
||||
midi events to pygame events.
|
||||
|
||||
::
|
||||
|
||||
MIDIIN
|
||||
MIDIOUT
|
||||
|
||||
|
|
||||
|
||||
.. function:: init
|
||||
|
||||
| :sl:`initialize the midi module`
|
||||
| :sg:`init() -> None`
|
||||
|
||||
Initializes the :mod:`pygame.midi` module. Must be called before using the
|
||||
:mod:`pygame.midi` module.
|
||||
|
||||
It is safe to call this more than once.
|
||||
|
||||
.. ## pygame.midi.init ##
|
||||
|
||||
.. function:: quit
|
||||
|
||||
| :sl:`uninitialize the midi module`
|
||||
| :sg:`quit() -> None`
|
||||
|
||||
Uninitializes the :mod:`pygame.midi` module. If :func:`pygame.midi.init` was
|
||||
called to initialize the :mod:`pygame.midi` module, then this function will
|
||||
be called automatically when your program exits.
|
||||
|
||||
It is safe to call this function more than once.
|
||||
|
||||
.. ## pygame.midi.quit ##
|
||||
|
||||
.. function:: get_init
|
||||
|
||||
| :sl:`returns True if the midi module is currently initialized`
|
||||
| :sg:`get_init() -> bool`
|
||||
|
||||
Gets the initialization state of the :mod:`pygame.midi` module.
|
||||
|
||||
:returns: ``True`` if the :mod:`pygame.midi` module is currently initialized.
|
||||
:rtype: bool
|
||||
|
||||
.. versionaddedold:: 1.9.5
|
||||
|
||||
.. ## pygame.midi.get_init ##
|
||||
|
||||
.. class:: Input
|
||||
|
||||
| :sl:`Input is used to get midi input from midi devices.`
|
||||
| :sg:`Input(device_id) -> None`
|
||||
| :sg:`Input(device_id, buffer_size) -> None`
|
||||
|
||||
:param int device_id: midi device id
|
||||
:param int buffer_size: (optional) the number of input events to be buffered
|
||||
|
||||
.. method:: close
|
||||
|
||||
| :sl:`closes a midi stream, flushing any pending buffers.`
|
||||
| :sg:`close() -> None`
|
||||
|
||||
PortMidi attempts to close open streams when the application exits.
|
||||
|
||||
.. note:: This is particularly difficult under Windows.
|
||||
|
||||
.. ## Input.close ##
|
||||
|
||||
.. method:: poll
|
||||
|
||||
| :sl:`returns True if there's data, or False if not.`
|
||||
| :sg:`poll() -> bool`
|
||||
|
||||
Used to indicate if any data exists.
|
||||
|
||||
:returns: ``True`` if there is data, ``False`` otherwise
|
||||
:rtype: bool
|
||||
|
||||
:raises MidiException: on error
|
||||
|
||||
.. ## Input.poll ##
|
||||
|
||||
.. method:: read
|
||||
|
||||
| :sl:`reads num_events midi events from the buffer.`
|
||||
| :sg:`read(num_events) -> midi_event_list`
|
||||
|
||||
Reads from the input buffer and gives back midi events.
|
||||
|
||||
:param int num_events: number of input events to read
|
||||
|
||||
:returns: the format for midi_event_list is
|
||||
``[[[status, data1, data2, data3], timestamp], ...]``
|
||||
:rtype: list
|
||||
|
||||
.. ## Input.read ##
|
||||
|
||||
.. ## pygame.midi.Input ##
|
||||
|
||||
.. class:: Output
|
||||
|
||||
| :sl:`Output is used to send midi to an output device`
|
||||
| :sg:`Output(device_id) -> None`
|
||||
| :sg:`Output(device_id, latency=0) -> None`
|
||||
| :sg:`Output(device_id, buffer_size=256) -> None`
|
||||
| :sg:`Output(device_id, latency, buffer_size) -> None`
|
||||
|
||||
The ``buffer_size`` specifies the number of output events to be buffered
|
||||
waiting for output. In some cases (see below) PortMidi does not buffer
|
||||
output at all and merely passes data to a lower-level API, in which case
|
||||
buffersize is ignored.
|
||||
|
||||
``latency`` is the delay in milliseconds applied to timestamps to determine
|
||||
when the output should actually occur. If ``latency`` is <<0, 0 is assumed.
|
||||
|
||||
If ``latency`` is zero, timestamps are ignored and all output is delivered
|
||||
immediately. If ``latency`` is greater than zero, output is delayed until the
|
||||
message timestamp plus the ``latency``. In some cases, PortMidi can obtain
|
||||
better timing than your application by passing timestamps along to the
|
||||
device driver or hardware. Latency may also help you to synchronize midi
|
||||
data to audio data by matching midi latency to the audio buffer latency.
|
||||
|
||||
.. note::
|
||||
Time is measured relative to the time source indicated by time_proc.
|
||||
Timestamps are absolute, not relative delays or offsets.
|
||||
|
||||
.. method:: abort
|
||||
|
||||
| :sl:`terminates outgoing messages immediately`
|
||||
| :sg:`abort() -> None`
|
||||
|
||||
The caller should immediately close the output port; this call may result
|
||||
in transmission of a partial midi message. There is no abort for Midi
|
||||
input because the user can simply ignore messages in the buffer and close
|
||||
an input device at any time.
|
||||
|
||||
.. ## Output.abort ##
|
||||
|
||||
.. method:: close
|
||||
|
||||
| :sl:`closes a midi stream, flushing any pending buffers.`
|
||||
| :sg:`close() -> None`
|
||||
|
||||
PortMidi attempts to close open streams when the application exits.
|
||||
|
||||
.. note:: This is particularly difficult under Windows.
|
||||
|
||||
.. ## Output.close ##
|
||||
|
||||
.. method:: note_off
|
||||
|
||||
| :sl:`turns a midi note off (note must be on)`
|
||||
| :sg:`note_off(note, velocity=None, channel=0) -> None`
|
||||
|
||||
Turn a note off in the output stream. The note must already be on for
|
||||
this to work correctly.
|
||||
|
||||
.. ## Output.note_off ##
|
||||
|
||||
.. method:: note_on
|
||||
|
||||
| :sl:`turns a midi note on (note must be off)`
|
||||
| :sg:`note_on(note, velocity=None, channel=0) -> None`
|
||||
|
||||
Turn a note on in the output stream. The note must already be off for
|
||||
this to work correctly.
|
||||
|
||||
.. ## Output.note_on ##
|
||||
|
||||
.. method:: set_instrument
|
||||
|
||||
| :sl:`select an instrument, with a value between 0 and 127`
|
||||
| :sg:`set_instrument(instrument_id, channel=0) -> None`
|
||||
|
||||
Select an instrument.
|
||||
|
||||
.. ## Output.set_instrument ##
|
||||
|
||||
.. method:: pitch_bend
|
||||
|
||||
| :sl:`modify the pitch of a channel.`
|
||||
| :sg:`set_instrument(value=0, channel=0) -> None`
|
||||
|
||||
Adjust the pitch of a channel. The value is a signed integer
|
||||
from -8192 to +8191. For example, 0 means "no change", +4096 is
|
||||
typically a semitone higher, and -8192 is 1 whole tone lower (though
|
||||
the musical range corresponding to the pitch bend range can also be
|
||||
changed in some synthesizers).
|
||||
|
||||
If no value is given, the pitch bend is returned to "no change".
|
||||
|
||||
.. versionaddedold:: 1.9.4
|
||||
|
||||
.. method:: write
|
||||
|
||||
| :sl:`writes a list of midi data to the Output`
|
||||
| :sg:`write(data) -> None`
|
||||
|
||||
Writes series of MIDI information in the form of a list.
|
||||
|
||||
:param list data: data to write, the expected format is
|
||||
``[[[status, data1=0, data2=0, ...], timestamp], ...]``
|
||||
with the ``data#`` fields being optional
|
||||
|
||||
:raises IndexError: if more than 1024 elements in the data list
|
||||
|
||||
Example:
|
||||
::
|
||||
|
||||
# Program change at time 20000 and 500ms later send note 65 with
|
||||
# velocity 100.
|
||||
write([[[0xc0, 0, 0], 20000], [[0x90, 60, 100], 20500]])
|
||||
|
||||
.. note::
|
||||
- Timestamps will be ignored if latency = 0
|
||||
- To get a note to play immediately, send MIDI info with timestamp
|
||||
read from function Time
|
||||
- Optional data fields: ``write([[[0xc0, 0, 0], 20000]])`` is
|
||||
equivalent to ``write([[[0xc0], 20000]])``
|
||||
|
||||
.. ## Output.write ##
|
||||
|
||||
.. method:: write_short
|
||||
|
||||
| :sl:`writes up to 3 bytes of midi data to the Output`
|
||||
| :sg:`write_short(status) -> None`
|
||||
| :sg:`write_short(status, data1=0, data2=0) -> None`
|
||||
|
||||
Output MIDI information of 3 bytes or less. The ``data`` fields are
|
||||
optional and assumed to be 0 if omitted.
|
||||
|
||||
Examples of status byte values:
|
||||
::
|
||||
|
||||
0xc0 # program change
|
||||
0x90 # note on
|
||||
# etc.
|
||||
|
||||
Example:
|
||||
::
|
||||
|
||||
# note 65 on with velocity 100
|
||||
write_short(0x90, 65, 100)
|
||||
|
||||
.. ## Output.write_short ##
|
||||
|
||||
.. method:: write_sys_ex
|
||||
|
||||
| :sl:`writes a timestamped system-exclusive midi message.`
|
||||
| :sg:`write_sys_ex(when, msg) -> None`
|
||||
|
||||
Writes a timestamped system-exclusive midi message.
|
||||
|
||||
:param msg: midi message
|
||||
:type msg: list[int] or str
|
||||
:param when: timestamp in milliseconds
|
||||
|
||||
Example:
|
||||
::
|
||||
|
||||
midi_output.write_sys_ex(0, '\xF0\x7D\x10\x11\x12\x13\xF7')
|
||||
|
||||
# is equivalent to
|
||||
|
||||
midi_output.write_sys_ex(pygame.midi.time(),
|
||||
[0xF0, 0x7D, 0x10, 0x11, 0x12, 0x13, 0xF7])
|
||||
|
||||
.. ## Output.write_sys_ex ##
|
||||
|
||||
.. ## pygame.midi.Output ##
|
||||
|
||||
.. function:: get_count
|
||||
|
||||
| :sl:`gets the number of devices.`
|
||||
| :sg:`get_count() -> num_devices`
|
||||
|
||||
Device ids range from 0 to ``get_count() - 1``
|
||||
|
||||
.. ## pygame.midi.get_count ##
|
||||
|
||||
.. function:: get_default_input_id
|
||||
|
||||
| :sl:`gets default input device number`
|
||||
| :sg:`get_default_input_id() -> default_id`
|
||||
|
||||
The following describes the usage details for this function and the
|
||||
:func:`get_default_output_id` function.
|
||||
|
||||
Return the default device ID or ``-1`` if there are no devices. The result
|
||||
can be passed to the :class:`Input`/:class:`Output` class.
|
||||
|
||||
On a PC the user can specify a default device by setting an environment
|
||||
variable. To use device #1, for example:
|
||||
::
|
||||
|
||||
set PM_RECOMMENDED_INPUT_DEVICE=1
|
||||
or
|
||||
set PM_RECOMMENDED_OUTPUT_DEVICE=1
|
||||
|
||||
The user should first determine the available device ID by using the
|
||||
supplied application "testin" or "testout".
|
||||
|
||||
In general, the registry is a better place for this kind of info. With
|
||||
USB devices that can come and go, using integers is not very reliable
|
||||
for device identification. Under Windows, if ``PM_RECOMMENDED_INPUT_DEVICE``
|
||||
(or ``PM_RECOMMENDED_OUTPUT_DEVICE``) is NOT found in the environment,
|
||||
then the default device is obtained by looking for a string in the registry
|
||||
under:
|
||||
::
|
||||
|
||||
HKEY_LOCAL_MACHINE/SOFTWARE/PortMidi/Recommended_Input_Device
|
||||
or
|
||||
HKEY_LOCAL_MACHINE/SOFTWARE/PortMidi/Recommended_Output_Device
|
||||
|
||||
|
||||
The number of the first device with a substring that matches the
|
||||
string exactly is returned. For example, if the string in the registry is
|
||||
"USB" and device 1 is named "In USB MidiSport 1x1", then that will be
|
||||
the default input because it contains the string "USB".
|
||||
|
||||
In addition to the name, :func:`get_device_info()` returns "interf", which is
|
||||
the interface name. The "interface" is the underlying software system or
|
||||
API used by PortMidi to access devices. Supported interfaces:
|
||||
::
|
||||
|
||||
MMSystem # the only Win32 interface currently supported
|
||||
ALSA # the only Linux interface currently supported
|
||||
CoreMIDI # the only Mac OS X interface currently supported
|
||||
# DirectX - not implemented
|
||||
# OSS - not implemented
|
||||
|
||||
To specify both the interface and the device name in the registry, separate
|
||||
the two with a comma and a space. The string before the comma must be a
|
||||
substring of the "interf" string and the string after the space must be a
|
||||
substring of the "name" name string in order to match the device. e.g.:
|
||||
::
|
||||
|
||||
MMSystem, In USB MidiSport 1x1
|
||||
|
||||
.. note::
|
||||
In the current release, the default is simply the first device (the
|
||||
input or output device with the lowest PmDeviceID).
|
||||
|
||||
.. ## pygame.midi.get_default_input_id ##
|
||||
|
||||
.. function:: get_default_output_id
|
||||
|
||||
| :sl:`gets default output device number`
|
||||
| :sg:`get_default_output_id() -> default_id`
|
||||
|
||||
See :func:`get_default_input_id` for usage details.
|
||||
|
||||
.. ## pygame.midi.get_default_output_id ##
|
||||
|
||||
.. function:: get_device_info
|
||||
|
||||
| :sl:`returns information about a midi device`
|
||||
| :sg:`get_device_info(an_id) -> (interf, name, input, output, opened)`
|
||||
| :sg:`get_device_info(an_id) -> None`
|
||||
|
||||
Gets the device info for a given id.
|
||||
|
||||
:param int an_id: id of the midi device being queried
|
||||
|
||||
:returns: if the id is out of range ``None`` is returned, otherwise
|
||||
a tuple of (interf, name, input, output, opened) is returned.
|
||||
|
||||
- interf: string describing the device interface (e.g. 'ALSA')
|
||||
- name: string name of the device (e.g. 'Midi Through Port-0')
|
||||
- input: 1 if the device is an input device, otherwise 0
|
||||
- output: 1 if the device is an output device, otherwise 0
|
||||
- opened: 1 if the device is opened, otherwise 0
|
||||
:rtype: tuple or None
|
||||
|
||||
.. ## pygame.midi.get_device_info ##
|
||||
|
||||
.. function:: midis2events
|
||||
|
||||
| :sl:`converts midi events to pygame events`
|
||||
| :sg:`midis2events(midi_events, device_id) -> [Event, ...]`
|
||||
|
||||
Takes a sequence of midi events and returns list of pygame events.
|
||||
|
||||
The ``midi_events`` data is expected to be a sequence of
|
||||
``((status, data1, data2, data3), timestamp)`` midi events (all values
|
||||
required).
|
||||
|
||||
:returns: a list of pygame events of event type ``MIDIIN``
|
||||
:rtype: list
|
||||
|
||||
.. ## pygame.midi.midis2events ##
|
||||
|
||||
.. function:: time
|
||||
|
||||
| :sl:`returns the current time in ms of the PortMidi timer`
|
||||
| :sg:`time() -> time`
|
||||
|
||||
The time is reset to 0 when the :mod:`pygame.midi` module is initialized.
|
||||
|
||||
.. ## pygame.midi.time ##
|
||||
|
||||
|
||||
.. function:: frequency_to_midi
|
||||
|
||||
| :sl:`Converts a frequency into a MIDI note. Rounds to the closest midi note.`
|
||||
| :sg:`frequency_to_midi(midi_note) -> midi_note`
|
||||
|
||||
example:
|
||||
::
|
||||
|
||||
frequency_to_midi(27.5) == 21
|
||||
|
||||
.. versionaddedold:: 1.9.5
|
||||
|
||||
.. ## pygame.midi.frequency_to_midi ##
|
||||
|
||||
|
||||
.. function:: midi_to_frequency
|
||||
|
||||
| :sl:`Converts a midi note to a frequency.`
|
||||
| :sg:`midi_to_frequency(midi_note) -> frequency`
|
||||
|
||||
example:
|
||||
::
|
||||
|
||||
midi_to_frequency(21) == 27.5
|
||||
|
||||
.. versionaddedold:: 1.9.5
|
||||
|
||||
.. ## pygame.midi.midi_to_frequency ##
|
||||
|
||||
|
||||
.. function:: midi_to_ansi_note
|
||||
|
||||
| :sl:`Returns the Ansi Note name for a midi number.`
|
||||
| :sg:`midi_to_ansi_note(midi_note) -> ansi_note`
|
||||
|
||||
example:
|
||||
::
|
||||
|
||||
midi_to_ansi_note(21) == 'A0'
|
||||
|
||||
.. versionaddedold:: 1.9.5
|
||||
|
||||
.. ## pygame.midi.midi_to_ansi_note ##
|
||||
|
||||
.. exception:: MidiException
|
||||
|
||||
| :sl:`exception that pygame.midi functions and classes can raise`
|
||||
| :sg:`MidiException(errno) -> None`
|
||||
|
||||
.. ## pygame.midi.MidiException ##
|
||||
|
||||
|
||||
.. ## pygame.midi ##
|
||||
@@ -0,0 +1,780 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.mixer`
|
||||
===================
|
||||
|
||||
.. module:: pygame.mixer
|
||||
:synopsis: pygame module for loading and playing sounds
|
||||
|
||||
| :sl:`pygame module for loading and playing sounds`
|
||||
|
||||
This module contains classes for loading Sound objects and controlling
|
||||
playback.
|
||||
|
||||
The mixer module has a limited number of channels for playback of sounds.
|
||||
Usually programs tell pygame to start playing audio and it selects an available
|
||||
channel automatically. The default is 8 simultaneous channels, but complex
|
||||
programs can get more precise control over the number of channels and their
|
||||
use.
|
||||
|
||||
All sound playback is mixed in background threads. When you begin to play a
|
||||
Sound object, it will return immediately while the sound continues to play. A
|
||||
single Sound object can also be actively played back multiple times.
|
||||
|
||||
The mixer also has a special streaming channel. This is for music playback and
|
||||
is accessed through the :mod:`pygame.mixer.music` module. Consider using this
|
||||
module for playing long running music. Unlike mixer module, the music module
|
||||
streams the music from the files without loading music at once into memory.
|
||||
|
||||
The mixer module must be initialized like other pygame modules, but it has some
|
||||
extra conditions. The ``pygame.mixer.init()`` function takes several optional
|
||||
arguments to control the playback rate and sample size.
|
||||
|
||||
``NOTE``: For less laggy sound use a smaller buffer size. The default
|
||||
is set to reduce the chance of scratchy sounds on some computers. You can
|
||||
change the default buffer by calling :func:`pygame.mixer.pre_init` before
|
||||
:func:`pygame.mixer.init` or :func:`pygame.init` is called. For example:
|
||||
``pygame.mixer.pre_init(44100,-16,2, 1024)``
|
||||
|
||||
The following file formats are supported
|
||||
|
||||
* ``WAV``
|
||||
|
||||
* ``MP3``
|
||||
|
||||
* ``OGG``
|
||||
|
||||
* ``FLAC``
|
||||
|
||||
* ``OPUS``
|
||||
|
||||
* ``WV`` (WavPack)
|
||||
|
||||
* ``MOD`` ("Module file" family of music file formats)
|
||||
|
||||
* ``MIDI`` (see the :func:`get_soundfont` and :func:`set_soundfont` methods)
|
||||
|
||||
.. versionadded:: 2.5.0 Loading WV (Relies on SDL_mixer 2.8.0+)
|
||||
|
||||
|
||||
.. function:: init
|
||||
|
||||
| :sl:`initialize the mixer module`
|
||||
| :sg:`init(frequency=44100, size=-16, channels=2, buffer=512, devicename=None, allowedchanges=AUDIO_ALLOW_FREQUENCY_CHANGE | AUDIO_ALLOW_CHANNELS_CHANGE) -> None`
|
||||
|
||||
Initialize the mixer module for Sound loading and playback. The default
|
||||
arguments can be overridden to provide specific audio mixing. Keyword
|
||||
arguments are accepted. For backwards compatibility, argument values of
|
||||
0 are replaced with the startup defaults, except for ``allowedchanges``,
|
||||
where -1 is used. (startup defaults may be changed by a :func:`pre_init` call).
|
||||
|
||||
The size argument represents how many bits are used for each audio sample.
|
||||
If the value is negative then signed sample values will be used. Positive
|
||||
values mean unsigned audio samples will be used. An invalid value raises an
|
||||
exception.
|
||||
|
||||
The channels argument is used to specify whether to use mono or stereo. 1
|
||||
for mono and 2 for stereo.
|
||||
``NOTE``: The channels argument is not related to the number
|
||||
of channels for playback of sounds, that you can get with the function
|
||||
"get_num_channels" or set with the function "set_num_channels" (see below).
|
||||
|
||||
The buffer argument controls the number of internal samples used in the
|
||||
sound mixer. The default value should work for most cases. It can be lowered
|
||||
to reduce latency, but sound dropout may occur. It can be raised to larger
|
||||
values to ensure playback never skips, but it will impose latency on sound
|
||||
playback. The buffer size must be a power of two (if not it is rounded up to
|
||||
the next nearest power of 2).
|
||||
|
||||
The devicename parameter is the name of sound device to open for audio
|
||||
playback. Allowed device names will vary based on the host system.
|
||||
If left as ``None`` then a sensible default will be chosen for you.
|
||||
|
||||
Some platforms require the :mod:`pygame.mixer` module to be initialized
|
||||
after the display modules have initialized. The top level ``pygame.init()``
|
||||
takes care of this automatically, but cannot pass any arguments to the mixer
|
||||
init. To solve this, mixer has a function ``pygame.mixer.pre_init()`` to set
|
||||
the proper defaults before the toplevel init is used.
|
||||
|
||||
When using allowedchanges=0 it will convert the samples at runtime to match
|
||||
what the hardware supports. For example a sound card may not
|
||||
support 16bit sound samples, so instead it will use 8bit samples internally.
|
||||
If AUDIO_ALLOW_FORMAT_CHANGE is supplied, then the requested format will
|
||||
change to the closest that SDL supports.
|
||||
|
||||
Apart from 0, allowedchanged accepts the following constants ORed together:
|
||||
|
||||
- AUDIO_ALLOW_FREQUENCY_CHANGE
|
||||
- AUDIO_ALLOW_FORMAT_CHANGE
|
||||
- AUDIO_ALLOW_CHANNELS_CHANGE
|
||||
- AUDIO_ALLOW_ANY_CHANGE
|
||||
|
||||
It is safe to call this more than once, but after the mixer is initialized
|
||||
you cannot change the playback arguments without first calling
|
||||
``pygame.mixer.quit()``.
|
||||
|
||||
.. versionchangedold:: 1.8 The default ``buffersize`` changed from 1024 to 3072.
|
||||
.. versionchangedold:: 1.9.1 The default ``buffersize`` changed from 3072 to 4096.
|
||||
.. versionchangedold:: 2.0.0 The default ``buffersize`` changed from 4096 to 512.
|
||||
.. versionchangedold:: 2.0.0 The default ``frequency`` changed from 22050 to 44100.
|
||||
.. versionchangedold:: 2.0.0 ``size`` can be 32 (32-bit floats).
|
||||
.. versionchangedold:: 2.0.0 ``channels`` can also be 4 or 6.
|
||||
.. versionaddedold:: 2.0.0 ``allowedchanges``, ``devicename`` arguments added
|
||||
|
||||
.. ## pygame.mixer.init ##
|
||||
|
||||
.. function:: pre_init
|
||||
|
||||
| :sl:`preset the mixer init arguments`
|
||||
| :sg:`pre_init(frequency=44100, size=-16, channels=2, buffer=512, devicename=None, allowedchanges=AUDIO_ALLOW_FREQUENCY_CHANGE | AUDIO_ALLOW_CHANNELS_CHANGE) -> None`
|
||||
|
||||
Call pre_init to change the defaults used when the real
|
||||
``pygame.mixer.init()`` is called. Keyword arguments are accepted. The best
|
||||
way to set custom mixer playback values is to call
|
||||
``pygame.mixer.pre_init()`` before calling the top level ``pygame.init()``.
|
||||
For backwards compatibility, argument values of 0 are replaced with the
|
||||
startup defaults, except for ``allowedchanges``, where -1 is used.
|
||||
|
||||
.. versionchangedold:: 1.8 The default ``buffersize`` changed from 1024 to 3072.
|
||||
.. versionchangedold:: 1.9.1 The default ``buffersize`` changed from 3072 to 4096.
|
||||
.. versionchangedold:: 2.0.0 The default ``buffersize`` changed from 4096 to 512.
|
||||
.. versionchangedold:: 2.0.0 The default ``frequency`` changed from 22050 to 44100.
|
||||
.. versionaddedold:: 2.0.0 ``allowedchanges``, ``devicename`` arguments added
|
||||
|
||||
.. ## pygame.mixer.pre_init ##
|
||||
|
||||
.. function:: quit
|
||||
|
||||
| :sl:`uninitialize the mixer`
|
||||
| :sg:`quit() -> None`
|
||||
|
||||
This will uninitialize :mod:`pygame.mixer`. All playback will stop and any
|
||||
loaded Sound objects may not be compatible with the mixer if it is
|
||||
reinitialized later.
|
||||
|
||||
.. ## pygame.mixer.quit ##
|
||||
|
||||
.. function:: get_init
|
||||
|
||||
| :sl:`test if the mixer is initialized`
|
||||
| :sg:`get_init() -> (frequency, format, channels) | None`
|
||||
|
||||
If the mixer is initialized, this returns the playback arguments it is
|
||||
using. If the mixer has not been initialized this returns ``None``.
|
||||
|
||||
.. ## pygame.mixer.get_init ##
|
||||
|
||||
.. function:: get_driver
|
||||
|
||||
| :sl:`get the name of the current audio backend driver`
|
||||
| :sg:`get_driver() -> str`
|
||||
|
||||
Pygame chooses one of many available audio backend drivers when it is
|
||||
initialized. This returns the internal name used for the backend. This
|
||||
function is intended to be used for getting diagnostic/debugging information.
|
||||
This can be controlled with ``SDL_AUDIODRIVER`` environment variable.
|
||||
|
||||
.. versionadded:: 2.5.0
|
||||
|
||||
.. function:: stop
|
||||
|
||||
| :sl:`stop playback of all sound channels`
|
||||
| :sg:`stop() -> None`
|
||||
|
||||
This will stop all playback of all active mixer channels.
|
||||
|
||||
.. ## pygame.mixer.stop ##
|
||||
|
||||
.. function:: pause
|
||||
|
||||
| :sl:`temporarily stop playback of all sound channels`
|
||||
| :sg:`pause() -> None`
|
||||
|
||||
This will temporarily stop all playback on the active mixer channels. The
|
||||
playback can later be resumed with ``pygame.mixer.unpause()``
|
||||
|
||||
.. ## pygame.mixer.pause ##
|
||||
|
||||
.. function:: unpause
|
||||
|
||||
| :sl:`resume paused playback of sound channels`
|
||||
| :sg:`unpause() -> None`
|
||||
|
||||
This will resume all active sound channels after they have been paused.
|
||||
|
||||
.. ## pygame.mixer.unpause ##
|
||||
|
||||
.. function:: fadeout
|
||||
|
||||
| :sl:`fade out the volume on all sounds before stopping`
|
||||
| :sg:`fadeout(time, /) -> None`
|
||||
|
||||
This will fade out the volume on all active channels over the time argument
|
||||
in milliseconds. After the sound is muted the playback will stop.
|
||||
|
||||
.. ## pygame.mixer.fadeout ##
|
||||
|
||||
.. function:: set_num_channels
|
||||
|
||||
| :sl:`set the total number of playback channels`
|
||||
| :sg:`set_num_channels(count, /) -> None`
|
||||
|
||||
Sets the number of available playback channels for the mixer. The default value is 8.
|
||||
The value can be increased or decreased. If the value is decreased, sounds
|
||||
playing on the truncated channels are stopped.
|
||||
|
||||
.. ## pygame.mixer.set_num_channels ##
|
||||
|
||||
.. function:: get_num_channels
|
||||
|
||||
| :sl:`get the total number of playback channels`
|
||||
| :sg:`get_num_channels() -> count`
|
||||
|
||||
Returns the number of currently active playback channels.
|
||||
|
||||
.. ## pygame.mixer.get_num_channels ##
|
||||
|
||||
.. function:: set_reserved
|
||||
|
||||
| :sl:`reserve channels from being automatically used`
|
||||
| :sg:`set_reserved(count, /) -> count`
|
||||
|
||||
The mixer can reserve any number of channels that will not be automatically
|
||||
selected for playback by Sounds. This means that whenever you play a Sound
|
||||
without specifying a channel, a reserved channel will never be used. If sounds
|
||||
are currently playing on the reserved channels they will not be stopped.
|
||||
|
||||
This allows the application to reserve a specific number of channels for
|
||||
important sounds that must not be dropped or have a guaranteed channel to
|
||||
play on.
|
||||
|
||||
Will return number of channels actually reserved, this may be less than requested
|
||||
depending on the number of channels previously allocated.
|
||||
|
||||
.. ## pygame.mixer.set_reserved ##
|
||||
|
||||
.. function:: find_channel
|
||||
|
||||
| :sl:`find an unused channel`
|
||||
| :sg:`find_channel(force=False) -> Channel | None`
|
||||
|
||||
This will find and return an inactive Channel object. If there are no
|
||||
inactive Channels this function will return ``None``. If there are no
|
||||
inactive channels and the force argument is ``True``, this will find the
|
||||
Channel with the longest running Sound and return it.
|
||||
|
||||
.. ## pygame.mixer.find_channel ##
|
||||
|
||||
.. function:: set_soundfont
|
||||
|
||||
| :sl:`set the soundfont for playing midi music`
|
||||
| :sg:`set_soundfont(path, /) -> None`
|
||||
|
||||
This sets the soundfont file to be used in the playback of midi music.
|
||||
The soundfont only affects the playback of ``MID``, ``MIDI``, and ``KAR`` file formats.
|
||||
The optional ``path`` argument, a string (or multiple strings separated by a semi-colon),
|
||||
must point to the soundfont file(s) to be searched for in order given if some
|
||||
are missing. If ``path`` is an empty string or the default (``None``), any specified soundfont paths
|
||||
will be cleared from the mixer.
|
||||
|
||||
Note on Windows, the mixer always uses the built-in soundfont instead of the one specified.
|
||||
|
||||
Function :func:`set_soundfont` calls underlying SDL_mixer function
|
||||
``Mix_SetSoundFonts``.
|
||||
|
||||
.. versionadded:: 2.3.1
|
||||
|
||||
.. ## pygame.mixer.set_soundfont ##
|
||||
|
||||
.. function:: get_soundfont
|
||||
|
||||
| :sl:`get the soundfont for playing midi music`
|
||||
| :sg:`get_soundfont() -> paths`
|
||||
|
||||
This gets the soundfont filepaths as a string (each path is separated by a semi-colon)
|
||||
to be used in the playback of ``MID``, ``MIDI``, and ``KAR`` music file formats. If no
|
||||
soundfont is specified, the return type is ``None``.
|
||||
|
||||
Function :func:`get_soundfont` calls underlying SDL_mixer function
|
||||
``Mix_GetSoundFonts``.
|
||||
|
||||
.. versionadded:: 2.3.1
|
||||
|
||||
.. ## pygame.mixer.get_soundfont ##
|
||||
|
||||
.. function:: get_busy
|
||||
|
||||
| :sl:`test if any sound is being mixed`
|
||||
| :sg:`get_busy() -> bool`
|
||||
|
||||
Returns ``True`` if the mixer is busy mixing any channels. If the mixer is
|
||||
idle or uninitialized then this returns ``False``.
|
||||
|
||||
.. ## pygame.mixer.get_busy ##
|
||||
|
||||
.. function:: get_sdl_mixer_version
|
||||
|
||||
| :sl:`get the mixer's SDL version`
|
||||
| :sg:`get_sdl_mixer_version() -> (major, minor, patch)`
|
||||
| :sg:`get_sdl_mixer_version(linked=True) -> (major, minor, patch)`
|
||||
|
||||
:param bool linked: if ``True`` (default) the linked version number is
|
||||
returned, otherwise the compiled version number is returned
|
||||
|
||||
:returns: the mixer's SDL library version number (linked or compiled
|
||||
depending on the ``linked`` parameter) as a tuple of 3 integers
|
||||
``(major, minor, patch)``
|
||||
:rtype: tuple
|
||||
|
||||
.. note::
|
||||
The linked and compiled version numbers should be the same.
|
||||
|
||||
.. versionaddedold:: 2.0.0
|
||||
|
||||
.. ## pygame.mixer.get_sdl_mixer_version ##
|
||||
|
||||
.. class:: Sound
|
||||
|
||||
| :sl:`Create a new Sound object from a file or buffer object`
|
||||
| :sg:`Sound(filename) -> Sound`
|
||||
| :sg:`Sound(file=filename) -> Sound`
|
||||
| :sg:`Sound(file=pathlib_path) -> Sound`
|
||||
| :sg:`Sound(buffer) -> Sound`
|
||||
| :sg:`Sound(buffer=buffer) -> Sound`
|
||||
| :sg:`Sound(object) -> Sound`
|
||||
| :sg:`Sound(file=object) -> Sound`
|
||||
| :sg:`Sound(array=object) -> Sound`
|
||||
|
||||
Load a new sound buffer from a filename, a python file object or a readable
|
||||
buffer object. Limited resampling will be performed to help the sample match
|
||||
the initialize arguments for the mixer. A Unicode string can only be a file
|
||||
pathname. A bytes object can be either a pathname or a buffer object.
|
||||
Use the 'file' or 'buffer' keywords to avoid ambiguity; otherwise Sound may
|
||||
guess wrong. If the array keyword is used, the object is expected to export
|
||||
a new buffer interface (The object is checked for a buffer interface first.)
|
||||
|
||||
The Sound object represents actual sound sample data. Methods that change
|
||||
the state of the Sound object will impact all instances of the Sound playback.
|
||||
A Sound object also exports a new buffer interface.
|
||||
|
||||
The Sound can be loaded from an ``OGG`` audio file or from an uncompressed
|
||||
``WAV``.
|
||||
|
||||
Note: The buffer will be copied internally, no data will be shared between
|
||||
it and the Sound object.
|
||||
|
||||
For now buffer and array support is consistent with ``sndarray.make_sound``
|
||||
for NumPy arrays, in that sample sign and byte order are ignored. This
|
||||
will change, either by correctly handling sign and byte order, or by raising
|
||||
an exception when different. Also, source samples are truncated to fit the
|
||||
audio sample size. This will not change.
|
||||
|
||||
.. note:: ``bytes(Sound)`` and ``bytearray(Sound)`` make use of the buffer
|
||||
interface, which is implemented internally by ``pygame.mixer.Sound``.
|
||||
Because of this, there is no need to directly implement ``__bytes__``.
|
||||
|
||||
.. versionaddedold:: 1.8 ``pygame.mixer.Sound(buffer)``
|
||||
.. versionaddedold:: 1.9.2
|
||||
:class:`pygame.mixer.Sound` keyword arguments and array interface support
|
||||
.. versionaddedold:: 2.0.1 pathlib.Path support on Python 3.
|
||||
|
||||
.. versionchanged:: 2.5.2 This class is also available through the ``pygame.Sound``
|
||||
alias.
|
||||
|
||||
.. method:: play
|
||||
|
||||
| :sl:`begin sound playback`
|
||||
| :sg:`play(loops=0, maxtime=0, fade_ms=0) -> Channel`
|
||||
|
||||
Begin playback of the Sound (i.e., on the computer's speakers) on an
|
||||
available Channel. This will forcibly select a Channel, so playback may
|
||||
cut off a currently playing sound if necessary.
|
||||
|
||||
The loops argument controls how many times the sample will be repeated
|
||||
after being played the first time. A value of 5 means that the sound will
|
||||
be played once, then repeated five times, and so is played a total of six
|
||||
times. The default value (zero) means the Sound is not repeated, and so
|
||||
is only played once. If loops is set to -1 the Sound will loop
|
||||
indefinitely (though you can still call ``stop()`` to stop it).
|
||||
|
||||
The maxtime argument can be used to stop playback after a given number of
|
||||
milliseconds.
|
||||
|
||||
The fade_ms argument will make the sound start playing at 0 volume and
|
||||
fade up to full volume over the time given. The sample may end before the
|
||||
fade-in is complete.
|
||||
|
||||
This returns the Channel object for the channel that was selected.
|
||||
|
||||
.. ## Sound.play ##
|
||||
|
||||
.. method:: stop
|
||||
|
||||
| :sl:`stop sound playback`
|
||||
| :sg:`stop() -> None`
|
||||
|
||||
This will stop the playback of this Sound on any active Channels.
|
||||
|
||||
.. ## Sound.stop ##
|
||||
|
||||
.. method:: fadeout
|
||||
|
||||
| :sl:`stop sound playback after fading out`
|
||||
| :sg:`fadeout(time, /) -> None`
|
||||
|
||||
This will stop playback of the sound after fading it out over the time
|
||||
argument in milliseconds. The Sound will fade and stop on all actively
|
||||
playing channels.
|
||||
|
||||
.. ## Sound.fadeout ##
|
||||
|
||||
.. method:: set_volume
|
||||
|
||||
| :sl:`set the playback volume for this Sound`
|
||||
| :sg:`set_volume(value, /) -> None`
|
||||
|
||||
This will set the playback volume (loudness) for this Sound. This will
|
||||
immediately affect the Sound if it is playing. It will also affect any
|
||||
future playback of this Sound.
|
||||
|
||||
:param float value: volume in the range of 0.0 to 1.0 (inclusive)
|
||||
|
||||
| If value < 0.0, the volume will not be changed
|
||||
| If value > 1.0, the volume will be set to 1.0
|
||||
|
||||
.. note::
|
||||
The values are internally converted and kept as integer values in range [0, 128], which means
|
||||
that ``get_volume()`` may return a different volume than it was set to. For example,
|
||||
|
||||
>>> sound.set_volume(0.1)
|
||||
>>> sound.get_volume()
|
||||
0.09375
|
||||
|
||||
This is because when you ``set_volume(0.1)``, the volume is internally calculated like so
|
||||
|
||||
>>> int(0.1 * 128)
|
||||
12
|
||||
|
||||
This means that some of the precision is lost, so when you retrieve it again using ``get_volume()``,
|
||||
it is converted back to a ``float`` using that integer
|
||||
|
||||
>>> 12 / 128
|
||||
0.09375
|
||||
|
||||
.. ## Sound.set_volume ##
|
||||
|
||||
.. method:: get_volume
|
||||
|
||||
| :sl:`get the playback volume`
|
||||
| :sg:`get_volume() -> value`
|
||||
|
||||
Return a value from 0.0 to 1.0 (inclusive) representing the volume for this Sound.
|
||||
|
||||
.. note::
|
||||
See :func:`Sound.set_volume` for more information regarding the returned value
|
||||
|
||||
.. ## Sound.get_volume ##
|
||||
|
||||
.. method:: get_num_channels
|
||||
|
||||
| :sl:`count how many times this Sound is playing`
|
||||
| :sg:`get_num_channels() -> count`
|
||||
|
||||
Return the number of active channels this sound is playing on.
|
||||
|
||||
.. ## Sound.get_num_channels ##
|
||||
|
||||
.. method:: get_length
|
||||
|
||||
| :sl:`get the length of the Sound`
|
||||
| :sg:`get_length() -> seconds`
|
||||
|
||||
Return the length of this Sound in seconds.
|
||||
|
||||
.. ## Sound.get_length ##
|
||||
|
||||
.. method:: get_raw
|
||||
|
||||
| :sl:`return a bytestring copy of the Sound samples.`
|
||||
| :sg:`get_raw() -> bytes`
|
||||
|
||||
Return a copy of the Sound object buffer as a bytes.
|
||||
|
||||
.. versionaddedold:: 1.9.2
|
||||
|
||||
.. ## Sound.get_raw ##
|
||||
|
||||
.. method:: copy
|
||||
|
||||
| :sl:`return a new Sound object that is a deep copy of this Sound`
|
||||
| :sg:`copy() -> Sound`
|
||||
| :sg:`copy.copy(original_sound) -> Sound`
|
||||
|
||||
Return a new Sound object that is a deep copy of this Sound. The new Sound
|
||||
will be just as if you loaded it from the same file on disk as you did the
|
||||
original Sound. If the copy fails, a ``TypeError`` or :meth:`pygame.error`
|
||||
exception will be raised.
|
||||
|
||||
If copying a subclass of ``mixer.Sound``, an instance of the same subclass
|
||||
will be returned.
|
||||
|
||||
Also note that this functions as ``Sound.__copy__``.
|
||||
|
||||
.. versionadded:: 2.5.6
|
||||
|
||||
.. ## Sound.copy ##
|
||||
|
||||
.. ## pygame.mixer.Sound ##
|
||||
|
||||
.. class:: Channel
|
||||
|
||||
| :sl:`Create a Channel object for controlling playback`
|
||||
| :sg:`Channel(id) -> Channel`
|
||||
|
||||
Return a Channel object for one of the current channels. The id must be a
|
||||
value from 0 up to, but not including, ``pygame.mixer.get_num_channels()``.
|
||||
|
||||
The Channel object can be used to get fine control over the playback of
|
||||
Sounds. A channel can only playback a single Sound at time. Using channels
|
||||
is entirely optional since pygame can manage them by default.
|
||||
|
||||
.. versionchanged:: 2.1.4 This class is also available through the ``pygame.Channel``
|
||||
alias.
|
||||
.. versionchanged:: 2.4.0 It is now possible to create subclasses of ``pygame.mixer.Channel``
|
||||
|
||||
.. attribute:: id
|
||||
|
||||
| :sl:`get the channel id for the Channel object`
|
||||
| :sg:`id -> int`
|
||||
|
||||
This simply returns the channel id used to create the ``Channel`` instance
|
||||
as a read-only attribute
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Channel.id ##
|
||||
|
||||
.. method:: play
|
||||
|
||||
| :sl:`play a Sound on a specific Channel`
|
||||
| :sg:`play(Sound, loops=0, maxtime=0, fade_ms=0) -> None`
|
||||
|
||||
This will begin playback of a Sound on a specific Channel. If the Channel
|
||||
is currently playing any other Sound it will be stopped.
|
||||
|
||||
The loops argument has the same meaning as in ``Sound.play()``: it is the
|
||||
number of times to repeat the sound after the first time. If it is 3, the
|
||||
sound will be played 4 times (the first time, then three more). If loops
|
||||
is -1 then the playback will repeat indefinitely.
|
||||
|
||||
As in ``Sound.play()``, the maxtime argument can be used to stop playback
|
||||
of the Sound after a given number of milliseconds.
|
||||
|
||||
As in ``Sound.play()``, the fade_ms argument can be used fade in the
|
||||
sound.
|
||||
|
||||
.. ## Channel.play ##
|
||||
|
||||
.. method:: stop
|
||||
|
||||
| :sl:`stop playback on a Channel`
|
||||
| :sg:`stop() -> None`
|
||||
|
||||
Stop sound playback on a channel. After playback is stopped the channel
|
||||
becomes available for new Sounds to play on it.
|
||||
|
||||
.. ## Channel.stop ##
|
||||
|
||||
.. method:: pause
|
||||
|
||||
| :sl:`temporarily stop playback of a channel`
|
||||
| :sg:`pause() -> None`
|
||||
|
||||
Temporarily stop the playback of sound on a channel. It can be resumed at
|
||||
a later time with ``Channel.unpause()``
|
||||
|
||||
.. ## Channel.pause ##
|
||||
|
||||
.. method:: unpause
|
||||
|
||||
| :sl:`resume pause playback of a channel`
|
||||
| :sg:`unpause() -> None`
|
||||
|
||||
Resume the playback on a paused channel.
|
||||
|
||||
.. ## Channel.unpause ##
|
||||
|
||||
.. method:: fadeout
|
||||
|
||||
| :sl:`stop playback after fading channel out`
|
||||
| :sg:`fadeout(time, /) -> None`
|
||||
|
||||
Stop playback of a channel after fading out the sound over the given time
|
||||
argument in milliseconds.
|
||||
|
||||
.. ## Channel.fadeout ##
|
||||
|
||||
.. method:: set_source_location
|
||||
|
||||
| :sl:`set the position of a playing channel`
|
||||
| :sg:`set_source_location(angle, distance, /) -> None`
|
||||
|
||||
Set the position (angle, distance) of a playing channel.
|
||||
|
||||
`angle`: Angle in degrees.
|
||||
|
||||
`distance`: Range from 0 to 255.
|
||||
|
||||
.. warning:: This function currently fails and raises a
|
||||
:exc:`pygame.error` when using 7.1 surround sound.
|
||||
By default, the mixer module will use what the hardware is best
|
||||
suited for, so this leads to hardware specific exceptions when using
|
||||
this function.
|
||||
|
||||
One way of avoiding this is only using :func:`set_source_location`
|
||||
with forced stereo. For example:
|
||||
|
||||
::
|
||||
|
||||
pygame.mixer.pre_init(
|
||||
channels=2,
|
||||
allowedchanges=pygame.AUDIO_ALLOW_FREQUENCY_CHANGE,
|
||||
)
|
||||
pygame.init()
|
||||
|
||||
.. versionadded:: 2.3.0
|
||||
|
||||
.. ## Channel.set_source_location ##
|
||||
|
||||
.. method:: set_volume
|
||||
|
||||
| :sl:`set the volume of a playing channel`
|
||||
| :sg:`set_volume(value, /) -> None`
|
||||
| :sg:`set_volume(left, right, /) -> None`
|
||||
|
||||
Set the volume (loudness) of a playing sound. When a channel starts to
|
||||
play its volume value is reset. This only affects the current sound. The
|
||||
value argument is in the range of 0.0 to 1.0 (inclusive).
|
||||
|
||||
If one argument is passed, it will be the volume of both speakers. If two
|
||||
arguments are passed and the mixer is in stereo mode, the first argument
|
||||
will be the volume of the left speaker and the second will be the volume
|
||||
of the right speaker.
|
||||
|
||||
If the channel is playing a Sound on which ``set_volume()`` has also been
|
||||
called, both calls are taken into account. For example:
|
||||
|
||||
::
|
||||
|
||||
sound = pygame.mixer.Sound("s.wav")
|
||||
channel = s.play() # Sound plays at full volume by default
|
||||
sound.set_volume(0.9) # Now plays at 90% of full volume.
|
||||
sound.set_volume(0.6) # Now plays at 60% (previous value replaced).
|
||||
channel.set_volume(0.5) # Now plays at 30% (0.6 * 0.5).
|
||||
|
||||
.. note::
|
||||
See :func:`Sound.set_volume` for more information regarding how the value is stored internally
|
||||
|
||||
.. ## Channel.set_volume ##
|
||||
|
||||
.. method:: get_volume
|
||||
|
||||
| :sl:`get the volume of the playing channel`
|
||||
| :sg:`get_volume() -> value`
|
||||
|
||||
Return the volume of the channel for the current playing sound
|
||||
in the range of 0.0 to 1.0 (inclusive). This does
|
||||
not take into account stereo separation used by
|
||||
:meth:`Channel.set_volume`. The Sound object also has its own volume
|
||||
which is mixed with the channel.
|
||||
|
||||
.. note::
|
||||
See :func:`Sound.set_volume` for more information regarding the returned value
|
||||
|
||||
.. ## Channel.get_volume ##
|
||||
|
||||
.. method:: get_busy
|
||||
|
||||
| :sl:`check if the channel is active`
|
||||
| :sg:`get_busy() -> bool`
|
||||
|
||||
Returns ``True`` if the channel is actively mixing sound. If the channel
|
||||
is idle this returns ``False``.
|
||||
|
||||
.. ## Channel.get_busy ##
|
||||
|
||||
.. method:: get_sound
|
||||
|
||||
| :sl:`get the currently playing Sound`
|
||||
| :sg:`get_sound() -> Sound | None`
|
||||
|
||||
Return the actual Sound object currently playing on this channel. If the
|
||||
channel is idle ``None`` is returned.
|
||||
|
||||
.. ## Channel.get_sound ##
|
||||
|
||||
.. method:: queue
|
||||
|
||||
| :sl:`queue a Sound object to follow the current`
|
||||
| :sg:`queue(sound, /) -> None`
|
||||
|
||||
When a Sound is queued on a Channel, it will begin playing immediately
|
||||
after the current Sound is finished. Each channel can only have a single
|
||||
Sound queued at a time. The queued Sound will only play if the current
|
||||
playback finished automatically. It is cleared on any other call to
|
||||
``Channel.stop()`` or ``Channel.play()``.
|
||||
|
||||
If there is no sound actively playing on the Channel then the Sound will
|
||||
begin playing immediately.
|
||||
|
||||
.. ## Channel.queue ##
|
||||
|
||||
.. method:: get_queue
|
||||
|
||||
| :sl:`return any Sound that is queued`
|
||||
| :sg:`get_queue() -> Sound | None`
|
||||
|
||||
If a Sound is already queued on this channel it will be returned. Once
|
||||
the queued sound begins playback it will no longer be on the queue.
|
||||
|
||||
.. ## Channel.get_queue ##
|
||||
|
||||
.. method:: set_endevent
|
||||
|
||||
| :sl:`have the channel send an event when playback stops`
|
||||
| :sg:`set_endevent() -> None`
|
||||
| :sg:`set_endevent(type, /) -> None`
|
||||
|
||||
When an endevent is set for a channel, it will send an event to the
|
||||
pygame queue every time a sound finishes playing on that channel (not
|
||||
just the first time). Use ``pygame.event.get()`` to retrieve the endevent
|
||||
once it's sent.
|
||||
|
||||
Note that if you called ``Sound.play(n)`` or ``Channel.play(sound,n)``,
|
||||
the end event is sent only once: after the sound has been played "n+1"
|
||||
times (see the documentation of Sound.play).
|
||||
|
||||
If ``Channel.stop()`` or ``Channel.play()`` is called while the sound was
|
||||
still playing, the event will be posted immediately.
|
||||
|
||||
The type argument will be the event id sent to the queue. This can be any
|
||||
valid event type, but a good choice would be a value between
|
||||
``pygame.locals.USEREVENT`` and ``pygame.locals.NUMEVENTS``. If no type
|
||||
argument is given then the Channel will stop sending endevents.
|
||||
|
||||
.. ## Channel.set_endevent ##
|
||||
|
||||
.. method:: get_endevent
|
||||
|
||||
| :sl:`get the event a channel sends when playback stops`
|
||||
| :sg:`get_endevent() -> type`
|
||||
|
||||
Returns the event type to be sent every time the Channel finishes
|
||||
playback of a Sound. If there is no endevent the function returns
|
||||
``pygame.NOEVENT``.
|
||||
|
||||
.. ## Channel.get_endevent ##
|
||||
|
||||
.. ## pygame.mixer.Channel ##
|
||||
|
||||
.. ## pygame.mixer ##
|
||||
@@ -0,0 +1,7 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.mouse`
|
||||
===================
|
||||
|
||||
.. autopgmodule:: pygame.mouse
|
||||
:members:
|
||||
@@ -0,0 +1,314 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.mixer.music`
|
||||
=========================
|
||||
|
||||
.. module:: pygame.mixer.music
|
||||
:synopsis: pygame module for controlling streamed audio
|
||||
|
||||
| :sl:`pygame module for controlling streamed audio`
|
||||
|
||||
The music module is closely tied to :mod:`pygame.mixer`. Use the music module
|
||||
to control the playback of music in the sound mixer.
|
||||
|
||||
The difference between the music playback and regular Sound playback is that
|
||||
the music is streamed, and never actually loaded all at once. The mixer system
|
||||
only supports a single music stream at once.
|
||||
|
||||
On older pygame versions, ``MP3`` support was limited under Mac and Linux. This
|
||||
changed in pygame ``v2.0.2`` which got improved MP3 support. Consider using
|
||||
``OGG`` file format for music as that can give slightly better compression than
|
||||
MP3 in most cases.
|
||||
|
||||
For a complete list of supported file formats, see the :mod:`pygame.mixer` doc page.
|
||||
|
||||
.. function:: load
|
||||
|
||||
| :sl:`Load a music file for playback`
|
||||
| :sg:`load(filename) -> None`
|
||||
| :sg:`load(fileobj, namehint="") -> None`
|
||||
|
||||
This will load a music filename/file object and prepare it for playback. If
|
||||
a music stream is already playing it will be stopped. This does not start
|
||||
the music playing.
|
||||
|
||||
If you are loading from a file object, the namehint parameter can be used to specify
|
||||
the type of music data in the object. For example: :code:`load(fileobj, "ogg")`.
|
||||
|
||||
.. versionchangedold:: 2.0.2 Added optional ``namehint`` argument
|
||||
.. versionchanged:: 2.2.0 Raises ``FileNotFoundError`` instead of :exc:`pygame.error` if file cannot be found
|
||||
|
||||
.. ## pygame.mixer.music.load ##
|
||||
|
||||
.. function:: unload
|
||||
|
||||
| :sl:`Unload the currently loaded music to free up resources`
|
||||
| :sg:`unload() -> None`
|
||||
|
||||
This closes resources like files for any music that may be loaded.
|
||||
|
||||
.. versionaddedold:: 2.0.0
|
||||
|
||||
.. ## pygame.mixer.music.load ##
|
||||
|
||||
|
||||
.. function:: play
|
||||
|
||||
| :sl:`Start the playback of the music stream`
|
||||
| :sg:`play(loops=0, start=0.0, fade_ms=0) -> None`
|
||||
|
||||
This will play the loaded music stream. If the music is already playing it
|
||||
will be restarted.
|
||||
|
||||
``loops`` is an optional integer argument, which is ``0`` by default, which
|
||||
indicates how many times to repeat the music. The music repeats indefinitely if
|
||||
this argument is set to ``-1``.
|
||||
|
||||
``start`` is an optional float argument, which is ``0.0`` by default, which
|
||||
denotes the position in time from which the music starts playing. The starting
|
||||
position depends on the format of the music played. ``MP3`` and ``OGG`` use
|
||||
the position as time in seconds. For ``MP3`` files the start time position
|
||||
selected may not be accurate as things like variable bit rate encoding and ID3
|
||||
tags can throw off the timing calculations. For ``MOD`` music it is the pattern
|
||||
order number. Passing a start position will raise a NotImplementedError if
|
||||
the start position cannot be set.
|
||||
|
||||
``fade_ms`` is an optional integer argument, which is ``0`` by default,
|
||||
which denotes the period of time (in milliseconds) over which the music
|
||||
will fade up from volume level ``0.0`` to full volume (or the volume level
|
||||
previously set by :func:`set_volume`). The sample may end before the fade-in
|
||||
is complete. If the music is already streaming ``fade_ms`` is ignored.
|
||||
|
||||
.. versionchangedold:: 2.0.0 Added optional ``fade_ms`` argument
|
||||
|
||||
.. ## pygame.mixer.music.play ##
|
||||
|
||||
.. function:: rewind
|
||||
|
||||
| :sl:`restart music`
|
||||
| :sg:`rewind() -> None`
|
||||
|
||||
Resets playback of the current music to the beginning. If :func:`pause` has
|
||||
previously been used to pause the music, the music will remain paused.
|
||||
|
||||
.. note:: :func:`rewind` supports a limited number of file types and notably
|
||||
``WAV`` files are NOT supported. For unsupported file types use :func:`play`
|
||||
which will restart the music that's already playing (note that this
|
||||
will start the music playing again even if previously paused).
|
||||
|
||||
.. ## pygame.mixer.music.rewind ##
|
||||
|
||||
.. function:: stop
|
||||
|
||||
| :sl:`stop the music playback`
|
||||
| :sg:`stop() -> None`
|
||||
|
||||
Stops the music playback if it is currently playing.
|
||||
endevent will be triggered, if set.
|
||||
It won't unload the music.
|
||||
|
||||
.. ## pygame.mixer.music.stop ##
|
||||
|
||||
.. function:: pause
|
||||
|
||||
| :sl:`temporarily stop music playback`
|
||||
| :sg:`pause() -> None`
|
||||
|
||||
Temporarily stop playback of the music stream. It can be resumed with the
|
||||
:func:`unpause` function.
|
||||
|
||||
.. ## pygame.mixer.music.pause ##
|
||||
|
||||
.. function:: unpause
|
||||
|
||||
| :sl:`resume paused music`
|
||||
| :sg:`unpause() -> None`
|
||||
|
||||
This will resume the playback of a music stream after it has been paused.
|
||||
|
||||
.. ## pygame.mixer.music.unpause ##
|
||||
|
||||
.. function:: fadeout
|
||||
|
||||
| :sl:`stop music playback after fading out`
|
||||
| :sg:`fadeout(time, /) -> None`
|
||||
|
||||
Fade out and stop the currently playing music.
|
||||
|
||||
The ``time`` argument denotes the integer milliseconds for which the
|
||||
fading effect is generated.
|
||||
|
||||
Note, that this function blocks until the music has faded out. Calls
|
||||
to :func:`fadeout` and :func:`set_volume` will have no effect during
|
||||
this time. If an event was set using :func:`set_endevent` it will be
|
||||
called after the music has faded.
|
||||
|
||||
.. ## pygame.mixer.music.fadeout ##
|
||||
|
||||
.. function:: set_volume
|
||||
|
||||
| :sl:`set the music volume`
|
||||
| :sg:`set_volume(volume, /) -> None`
|
||||
|
||||
Set the volume of the music playback.
|
||||
|
||||
The ``volume`` argument is a float between ``0.0`` and ``1.0`` that sets
|
||||
the volume level. When new music is loaded the volume is reset to full
|
||||
volume. If ``volume`` is a negative value it will be ignored and the
|
||||
volume will remain set at the current level. If the ``volume`` argument
|
||||
is greater than ``1.0``, the volume will be set to ``1.0``.
|
||||
|
||||
.. note::
|
||||
See :func:`mixer.Sound.set_volume()<pygame.mixer.Sound.set_volume>` for more information regarding how the value is stored internally
|
||||
|
||||
.. ## pygame.mixer.music.set_volume ##
|
||||
|
||||
.. function:: get_volume
|
||||
|
||||
| :sl:`get the music volume`
|
||||
| :sg:`get_volume() -> value`
|
||||
|
||||
Returns the current volume for the mixer. The value will be between ``0.0``
|
||||
and ``1.0``.
|
||||
|
||||
.. note::
|
||||
See :func:`mixer.Sound.set_volume()<pygame.mixer.Sound.set_volume>` for more information regarding the returned value
|
||||
|
||||
.. ## pygame.mixer.music.get_volume ##
|
||||
|
||||
.. function:: get_busy
|
||||
|
||||
| :sl:`check if the music stream is playing`
|
||||
| :sg:`get_busy() -> bool`
|
||||
|
||||
Returns True when the music stream is actively playing. When the music is
|
||||
idle this returns False. In pygame 2.0.1 and above this function returns
|
||||
False when the music is paused. In pygame 1 it returns True when the music
|
||||
is paused.
|
||||
|
||||
.. versionchangedold:: 2.0.1 Returns False when music paused.
|
||||
|
||||
.. ## pygame.mixer.music.get_busy ##
|
||||
|
||||
.. function:: set_pos
|
||||
|
||||
| :sl:`set position to play from`
|
||||
| :sg:`set_pos(pos, /) -> None`
|
||||
|
||||
This sets the position in the music file where playback will start.
|
||||
The meaning of "pos", a float (or a number that can be converted to a float),
|
||||
depends on the music format.
|
||||
|
||||
For ``MOD`` files, pos is the integer pattern number in the module.
|
||||
For ``OGG`` it is the absolute position, in seconds, from
|
||||
the beginning of the sound. For ``MP3`` files, it is the relative position,
|
||||
in seconds, from the current position. For absolute positioning in an ``MP3``
|
||||
file, first call :func:`rewind`.
|
||||
|
||||
Other file formats are unsupported. Newer versions of SDL_mixer have
|
||||
better positioning support than earlier ones. A :exc:`pygame.error` is
|
||||
raised if a particular format does not support positioning.
|
||||
|
||||
Function :func:`set_pos` calls underlying SDL_mixer function
|
||||
``Mix_SetMusicPosition``.
|
||||
|
||||
.. versionaddedold:: 1.9.2
|
||||
|
||||
.. ## pygame.mixer.music.set_pos ##
|
||||
|
||||
.. function:: get_pos
|
||||
|
||||
| :sl:`get the music play time`
|
||||
| :sg:`get_pos() -> time`
|
||||
|
||||
This gets the number of milliseconds that the music has been playing for.
|
||||
The returned time only represents how long the music has been playing; it
|
||||
does not take into account any starting position offsets.
|
||||
|
||||
Returns -1 if ``get_pos`` failed due to music not playing.
|
||||
|
||||
.. ## pygame.mixer.music.get_pos ##
|
||||
|
||||
.. function:: queue
|
||||
|
||||
| :sl:`queue a sound file to follow the current`
|
||||
| :sg:`queue(filename) -> None`
|
||||
| :sg:`queue(fileobj, namehint="", loops=0) -> None`
|
||||
|
||||
This will load a sound file and queue it. A queued sound file will begin as
|
||||
soon as the current sound naturally ends. Only one sound can be queued at a
|
||||
time. Queuing a new sound while another sound is queued will result in the
|
||||
new sound becoming the queued sound. Also, if the current sound is ever
|
||||
stopped or changed, the queued sound will be lost.
|
||||
|
||||
If you are loading from a file object, the namehint parameter can be used to specify
|
||||
the type of music data in the object. For example: :code:`queue(fileobj, "ogg")`.
|
||||
|
||||
The following example will play music by Bach six times, then play music by
|
||||
Mozart once:
|
||||
|
||||
::
|
||||
|
||||
pygame.mixer.music.load('bach.ogg')
|
||||
pygame.mixer.music.play(5) # Plays six times, not five!
|
||||
pygame.mixer.music.queue('mozart.ogg')
|
||||
|
||||
.. versionchangedold:: 2.0.2 Added optional ``namehint`` argument
|
||||
.. versionchanged:: 2.2.0 Raises ``FileNotFoundError`` instead of :exc:`pygame.error` if file cannot be found
|
||||
|
||||
.. ## pygame.mixer.music.queue ##
|
||||
|
||||
.. function:: set_endevent
|
||||
|
||||
| :sl:`have the music send an event when playback stops`
|
||||
| :sg:`set_endevent() -> None`
|
||||
| :sg:`set_endevent(type, /) -> None`
|
||||
|
||||
This causes pygame to signal (by means of the event queue) when the music is
|
||||
done playing. The argument determines the type of event that will be queued.
|
||||
|
||||
The event will be queued every time the music finishes, not just the first
|
||||
time. To stop the event from being queued, call this method with no
|
||||
argument.
|
||||
|
||||
.. ## pygame.mixer.music.set_endevent ##
|
||||
|
||||
.. function:: get_endevent
|
||||
|
||||
| :sl:`get the event a channel sends when playback stops`
|
||||
| :sg:`get_endevent() -> type`
|
||||
|
||||
Returns the event type to be sent every time the music finishes playback. If
|
||||
there is no endevent the function returns ``pygame.NOEVENT``.
|
||||
|
||||
.. ## pygame.mixer.music.get_endevent ##
|
||||
|
||||
.. ## pygame.mixer.music ##
|
||||
|
||||
.. function:: get_metadata
|
||||
|
||||
| :sl:`get metadata of the specified or currently loaded music stream`
|
||||
| :sg:`get_metadata() -> dict`
|
||||
| :sg:`get_metadata(filename) -> dict`
|
||||
| :sg:`get_metadata(fileobj, namehint="") -> dict`
|
||||
|
||||
If no arguments are passed returns a dictionary containing metadata
|
||||
of the currently loaded music stream, raises an exception if a music stream is not loaded.
|
||||
Available keys are ``"title"``, ``"album"``, ``"artist"``, ``"copyright"``.
|
||||
Values are strings containing corresponding retrieved metadata.
|
||||
If particular metadata was not found the value is an empty string.
|
||||
Here is an example:
|
||||
``{'title': 'Small Tone', 'album': 'Tones', 'artist': 'Audacity Generator', 'copyright': ''}``
|
||||
|
||||
Refer to the :func:`pygame.mixer.music.load` function for arguments regarding specifying a file or a file-like object
|
||||
whose metadata you want to retrieve. For this function all arguments are optional,
|
||||
however, specifying only the ``namehint`` will raise an exception.
|
||||
|
||||
Since the underlying functionality was introduced in version 2.6.0 of SDL_mixer,
|
||||
calling this function with an older version of SDL_mixer will return a dictionary
|
||||
with all values being set to empty strings. You can find your version of SDL_mixer
|
||||
by using :func:`pygame.mixer.get_sdl_mixer_version`.
|
||||
|
||||
.. versionadded:: 2.1.4
|
||||
|
||||
.. ## pygame.mixer.music.get_metadata ##
|
||||
@@ -0,0 +1,303 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:class:`pygame.PixelArray`
|
||||
==========================
|
||||
|
||||
.. currentmodule:: pygame
|
||||
|
||||
.. class:: PixelArray
|
||||
|
||||
| :sl:`pygame object for direct pixel access of surfaces`
|
||||
| :sg:`PixelArray(Surface) -> PixelArray`
|
||||
|
||||
The PixelArray wraps a Surface and provides direct access to the
|
||||
surface's pixels. A pixel array can be one or two dimensional.
|
||||
A two dimensional array, like its surface, is indexed [column, row].
|
||||
Pixel arrays support slicing, both for returning a subarray or
|
||||
for assignment. A pixel array sliced on a single column or row
|
||||
returns a one dimensional pixel array. Arithmetic and other operations
|
||||
are not supported. A pixel array can be safely assigned to itself.
|
||||
Finally, pixel arrays export an array struct interface, allowing
|
||||
them to interact with :mod:`pygame.pixelcopy` methods and NumPy
|
||||
arrays.
|
||||
|
||||
A PixelArray pixel item can be assigned a raw integer values, a
|
||||
:class:`pygame.Color` instance, or a (r, g, b[, a]) tuple.
|
||||
|
||||
::
|
||||
|
||||
pxarray[x, y] = 0xFF00FF
|
||||
pxarray[x, y] = pygame.Color(255, 0, 255)
|
||||
pxarray[x, y] = (255, 0, 255)
|
||||
|
||||
However, only a pixel's integer value is returned. So, to compare a pixel
|
||||
to a particular color the color needs to be first mapped using
|
||||
the :meth:`Surface.map_rgb()` method of the Surface object for which the
|
||||
PixelArray was created.
|
||||
|
||||
::
|
||||
|
||||
pxarray = pygame.PixelArray(surface)
|
||||
# Check, if the first pixel at the topleft corner is blue
|
||||
if pxarray[0, 0] == surface.map_rgb((0, 0, 255)):
|
||||
...
|
||||
|
||||
When assigning to a range of pixels, a non tuple sequence of colors or
|
||||
a PixelArray can be used as the value. For a sequence, the length must
|
||||
match the PixelArray width.
|
||||
|
||||
::
|
||||
|
||||
pxarray[a:b] = 0xFF00FF # set all pixels to 0xFF00FF
|
||||
pxarray[a:b] = (0xFF00FF, 0xAACCEE, ... ) # first pixel = 0xFF00FF,
|
||||
# second pixel = 0xAACCEE, ...
|
||||
pxarray[a:b] = [(255, 0, 255), (170, 204, 238), ...] # same as above
|
||||
pxarray[a:b] = [(255, 0, 255), 0xAACCEE, ...] # same as above
|
||||
pxarray[a:b] = otherarray[x:y] # slice sizes must match
|
||||
|
||||
For PixelArray assignment, if the right hand side array has a row length
|
||||
of 1, then the column is broadcast over the target array's rows. An
|
||||
array of height 1 is broadcast over the target's columns, and is equivalent
|
||||
to assigning a 1D PixelArray.
|
||||
|
||||
Subscript slices can also be used to assign to a rectangular subview of
|
||||
the target PixelArray.
|
||||
|
||||
::
|
||||
|
||||
# Create some new PixelArray objects providing a different view
|
||||
# of the original array/surface.
|
||||
newarray = pxarray[2:4, 3:5]
|
||||
otherarray = pxarray[::2, ::2]
|
||||
|
||||
Subscript slices can also be used to do fast rectangular pixel manipulations
|
||||
instead of iterating over the x or y axis. The
|
||||
|
||||
::
|
||||
|
||||
pxarray[::2, :] = (0, 0, 0) # Make even columns black.
|
||||
pxarray[::2] = (0, 0, 0) # Same as [::2, :]
|
||||
|
||||
During its lifetime, the PixelArray locks the surface, thus you explicitly
|
||||
have to close() it once it's not used any more and the surface should perform
|
||||
operations in the same scope. It is best to use it as a context manager
|
||||
using the with PixelArray(surf) as pixel_array: style. So it works on pypy too.
|
||||
|
||||
A simple ``:`` slice index for the column can be omitted.
|
||||
|
||||
::
|
||||
|
||||
pxarray[::2, ...] = (0, 0, 0) # Same as pxarray[::2, :]
|
||||
pxarray[...] = (255, 0, 0) # Same as pxarray[:]
|
||||
|
||||
A note about PixelArray to PixelArray assignment, for arrays with an
|
||||
item size of 3 (created from 24 bit surfaces) pixel values are translated
|
||||
from the source to the destinations format. The red, green, and blue
|
||||
color elements of each pixel are shifted to match the format of the
|
||||
target surface. For all other pixel sizes no such remapping occurs.
|
||||
This should change in later pygame releases, where format conversions
|
||||
are performed for all pixel sizes. To avoid code breakage when full mapped
|
||||
copying is implemented it is suggested PixelArray to PixelArray copies be
|
||||
only between surfaces of identical format.
|
||||
|
||||
.. versionaddedold:: 1.9.4
|
||||
|
||||
- close() method was added. For explicitly cleaning up.
|
||||
- being able to use PixelArray as a context manager for cleanup.
|
||||
- both of these are useful for when working without reference counting (pypy).
|
||||
|
||||
.. versionaddedold:: 1.9.2
|
||||
|
||||
- array struct interface
|
||||
- transpose method
|
||||
- broadcasting for a length 1 dimension
|
||||
|
||||
.. versionchangedold:: 1.9.2
|
||||
|
||||
- A 2D PixelArray can have a length 1 dimension.
|
||||
Only an integer index on a 2D PixelArray returns a 1D array.
|
||||
- For assignment, a tuple can only be a color. Any other sequence type
|
||||
is a sequence of colors.
|
||||
|
||||
|
||||
.. versionaddedold: 1.8.0
|
||||
Subscript support
|
||||
|
||||
.. versionaddedold: 1.8.1
|
||||
Methods :meth:`make_surface`, :meth:`replace`, :meth:`extract`, and
|
||||
:meth:`compare`
|
||||
|
||||
.. versionaddedold: 1.9.2
|
||||
Properties :attr:`itemsize`, :attr:`ndim`, :attr:`shape`,
|
||||
and :attr:`strides`
|
||||
|
||||
.. versionaddedold: 1.9.2
|
||||
Array struct interface
|
||||
|
||||
.. versionaddedold: 1.9.4
|
||||
Methods :meth:`close`
|
||||
|
||||
.. versionchanged:: 2.5.8
|
||||
Fixed incorrect color matching and writing on 24-bit surfaces whose
|
||||
byte layout did not match the platform default.
|
||||
|
||||
.. attribute:: surface
|
||||
|
||||
| :sl:`Gets the Surface the PixelArray uses.`
|
||||
| :sg:`surface -> Surface`
|
||||
|
||||
The Surface the PixelArray was created for.
|
||||
|
||||
.. ## PixelArray.surface ##
|
||||
|
||||
.. attribute:: itemsize
|
||||
|
||||
| :sl:`Returns the byte size of a pixel array item`
|
||||
| :sg:`itemsize -> int`
|
||||
|
||||
This is the same as :meth:`Surface.get_bytesize` for the
|
||||
pixel array's surface.
|
||||
|
||||
.. versionaddedold:: 1.9.2
|
||||
|
||||
.. attribute:: ndim
|
||||
|
||||
| :sl:`Returns the number of dimensions.`
|
||||
| :sg:`ndim -> int`
|
||||
|
||||
A pixel array can be 1 or 2 dimensional.
|
||||
|
||||
.. versionaddedold:: 1.9.2
|
||||
|
||||
.. attribute:: shape
|
||||
|
||||
| :sl:`Returns the array size.`
|
||||
| :sg:`shape -> tuple of int's`
|
||||
|
||||
A tuple or length :attr:`ndim` giving the length of each
|
||||
dimension. Analogous to :meth:`Surface.get_size`.
|
||||
|
||||
.. versionaddedold:: 1.9.2
|
||||
|
||||
.. attribute:: strides
|
||||
|
||||
| :sl:`Returns byte offsets for each array dimension.`
|
||||
| :sg:`strides -> tuple of int's`
|
||||
|
||||
A tuple or length :attr:`ndim` byte counts. When a stride is
|
||||
multiplied by the corresponding index it gives the offset
|
||||
of that index from the start of the array. A stride is negative
|
||||
for an array that has is inverted (has a negative step).
|
||||
|
||||
.. versionaddedold:: 1.9.2
|
||||
|
||||
.. method:: make_surface
|
||||
|
||||
| :sl:`Creates a new Surface from the current PixelArray.`
|
||||
| :sg:`make_surface() -> Surface`
|
||||
|
||||
Creates a new Surface from the current PixelArray. Depending on the
|
||||
current PixelArray the size, pixel order etc. will be different from the
|
||||
original Surface.
|
||||
|
||||
::
|
||||
|
||||
# Create a new surface flipped around the vertical axis.
|
||||
sf = pxarray[:,::-1].make_surface ()
|
||||
|
||||
.. versionaddedold:: 1.8.1
|
||||
|
||||
.. ## PixelArray.make_surface ##
|
||||
|
||||
.. method:: replace
|
||||
|
||||
| :sl:`Replaces the passed color in the PixelArray with another one.`
|
||||
| :sg:`replace(color, repcolor, distance=0, weights=(0.299, 0.587, 0.114)) -> None`
|
||||
|
||||
Replaces the pixels with the passed color in the PixelArray by changing
|
||||
them them to the passed replacement color.
|
||||
|
||||
It uses a simple weighted Euclidean distance formula to calculate the
|
||||
distance between the colors. The distance space ranges from 0.0 to 1.0
|
||||
and is used as threshold for the color detection. This causes the
|
||||
replacement to take pixels with a similar, but not exactly identical
|
||||
color, into account as well.
|
||||
|
||||
This is an in place operation that directly affects the pixels of the
|
||||
PixelArray.
|
||||
|
||||
.. versionaddedold:: 1.8.1
|
||||
|
||||
.. versionchanged:: 2.5.8
|
||||
Fixed incorrect color matching and writing on 24-bit surfaces whose
|
||||
byte layout did not match the platform default.
|
||||
|
||||
.. ## PixelArray.replace ##
|
||||
|
||||
.. method:: extract
|
||||
|
||||
| :sl:`Extracts the passed color from the PixelArray.`
|
||||
| :sg:`extract(color, distance=0, weights=(0.299, 0.587, 0.114)) -> PixelArray`
|
||||
|
||||
Extracts the passed color by changing all matching pixels to white, while
|
||||
non-matching pixels are changed to black. This returns a new PixelArray
|
||||
with the black/white color mask.
|
||||
|
||||
It uses a simple weighted Euclidean distance formula to calculate the
|
||||
distance between the colors. The distance space ranges from 0.0 to 1.0
|
||||
and is used as threshold for the color detection. This causes the
|
||||
extraction to take pixels with a similar, but not exactly identical
|
||||
color, into account as well.
|
||||
|
||||
.. versionaddedold:: 1.8.1
|
||||
|
||||
.. ## PixelArray.extract ##
|
||||
|
||||
.. method:: compare
|
||||
|
||||
| :sl:`Compares the PixelArray with another one.`
|
||||
| :sg:`compare(array, distance=0, weights=(0.299, 0.587, 0.114)) -> PixelArray`
|
||||
|
||||
Compares the contents of the PixelArray with those from the passed in
|
||||
PixelArray. It returns a new PixelArray with a black/white color mask
|
||||
that indicates the differences (black) of both arrays. Both PixelArray
|
||||
objects must have identical bit depths and dimensions.
|
||||
|
||||
It uses a simple weighted Euclidean distance formula to calculate the
|
||||
distance between the colors. The distance space ranges from 0.0 to 1.0
|
||||
and is used as a threshold for the color detection. This causes the
|
||||
comparison to mark pixels with a similar, but not exactly identical
|
||||
color, as white.
|
||||
|
||||
.. versionaddedold:: 1.8.1
|
||||
|
||||
.. ## PixelArray.compare ##
|
||||
|
||||
.. method:: transpose
|
||||
|
||||
| :sl:`Exchanges the x and y axis.`
|
||||
| :sg:`transpose() -> PixelArray`
|
||||
|
||||
This method returns a new view of the pixel array with the rows and
|
||||
columns swapped. So for a (w, h) sized array a (h, w) slice is returned.
|
||||
If an array is one dimensional, then a length 1 x dimension is added,
|
||||
resulting in a 2D pixel array.
|
||||
|
||||
.. versionaddedold:: 1.9.2
|
||||
|
||||
.. ## PixelArray.transpose ##
|
||||
|
||||
.. method:: close
|
||||
|
||||
| :sl:`Closes the PixelArray, and releases Surface lock.`
|
||||
| :sg:`close() -> PixelArray`
|
||||
|
||||
This method is for explicitly closing the PixelArray, and releasing
|
||||
a lock on the Surface.
|
||||
|
||||
.. versionaddedold:: 1.9.4
|
||||
|
||||
.. ## PixelArray.close ##
|
||||
|
||||
|
||||
.. ## pygame.PixelArray ##
|
||||
@@ -0,0 +1,7 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.pixelcopy`
|
||||
=======================
|
||||
|
||||
.. autopgmodule:: pygame.pixelcopy
|
||||
:members:
|
||||
@@ -0,0 +1,561 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame`
|
||||
=============
|
||||
|
||||
.. module:: pygame
|
||||
:synopsis: the top level pygame package
|
||||
|
||||
| :sl:`the top level pygame package`
|
||||
|
||||
The pygame package represents the top-level package for others to use. Pygame
|
||||
itself is broken into many submodules, but this does not affect programs that
|
||||
use pygame.
|
||||
|
||||
As a convenience, most of the top-level variables in pygame have been placed
|
||||
inside a module named :mod:`pygame.locals`. This is meant to be used with
|
||||
``from pygame.locals import *``, in addition to ``import pygame``.
|
||||
|
||||
When you ``import pygame`` all available pygame submodules are automatically
|
||||
imported. Be aware that some of the pygame modules are considered *optional*,
|
||||
and may not be available. In that case, pygame will provide a placeholder
|
||||
object instead of the module, which can be used to test for availability.
|
||||
|
||||
.. data:: IS_CE
|
||||
|
||||
| :sl:`exists if current pygame is pygame-ce`
|
||||
| :sg:`IS_CE = 1`
|
||||
|
||||
Use ``getattr(pygame, "IS_CE", False)`` to check if current pygame is pygame-ce
|
||||
|
||||
.. ## pygame.IS_CE ##
|
||||
|
||||
.. function:: init
|
||||
|
||||
| :sl:`initialize all imported pygame modules`
|
||||
| :sg:`init() -> (numpass, numfail)`
|
||||
|
||||
Initialize all imported pygame modules. No exceptions will be raised if a
|
||||
module fails, but the total number if successful and failed inits will be
|
||||
returned as a tuple. You can always initialize individual modules manually,
|
||||
but :func:`pygame.init` is a convenient way to get everything started. The
|
||||
``init()`` functions for individual modules will raise exceptions when they
|
||||
fail.
|
||||
|
||||
You may want to initialize the different modules separately to speed up your
|
||||
program or to not use modules your game does not require.
|
||||
|
||||
It is safe to call this ``init()`` more than once as repeated calls will have
|
||||
no effect. This is true even if you have ``pygame.quit()`` all the modules.
|
||||
|
||||
.. ## pygame.init ##
|
||||
|
||||
.. function:: quit
|
||||
|
||||
| :sl:`uninitialize all pygame modules`
|
||||
| :sg:`quit() -> None`
|
||||
|
||||
Uninitialize all pygame modules that have previously been initialized. When
|
||||
the Python interpreter shuts down, this method is called regardless, so your
|
||||
program should not need it, except when it wants to terminate its pygame
|
||||
resources and continue. It is safe to call this function more than once as
|
||||
repeated calls have no effect.
|
||||
|
||||
.. note::
|
||||
Calling :func:`pygame.quit` will not exit your program. Consider letting
|
||||
your program end in the same way a normal Python program will end.
|
||||
|
||||
.. ## pygame.quit ##
|
||||
|
||||
.. function:: get_init
|
||||
|
||||
| :sl:`returns True if pygame is currently initialized`
|
||||
| :sg:`get_init() -> bool`
|
||||
|
||||
Returns ``True`` if pygame is currently initialized.
|
||||
|
||||
.. versionaddedold:: 1.9.5
|
||||
|
||||
.. ## pygame.get_init ##
|
||||
|
||||
.. exception:: error
|
||||
|
||||
| :sl:`standard pygame exception`
|
||||
| :sg:`raise pygame.error(message)`
|
||||
|
||||
This exception is raised whenever a pygame or SDL operation fails. You
|
||||
can catch any anticipated problems and deal with the error. The exception is
|
||||
always raised with a descriptive message about the problem.
|
||||
|
||||
Derived from the ``RuntimeError`` exception, which can also be used to catch
|
||||
these raised errors.
|
||||
|
||||
.. ## pygame.error ##
|
||||
|
||||
.. function:: get_error
|
||||
|
||||
| :sl:`get the current error message`
|
||||
| :sg:`get_error() -> errorstr`
|
||||
|
||||
SDL maintains an internal error message. This message will usually be
|
||||
given to you when :func:`pygame.error` is raised, so this function will
|
||||
rarely be needed.
|
||||
|
||||
.. ## pygame.get_error ##
|
||||
|
||||
.. function:: set_error
|
||||
|
||||
| :sl:`set the current error message`
|
||||
| :sg:`set_error(error_msg, /) -> None`
|
||||
|
||||
SDL maintains an internal error message. This message will usually be
|
||||
given to you when :func:`pygame.error` is raised, so this function will
|
||||
rarely be needed.
|
||||
|
||||
.. ## pygame.set_error ##
|
||||
|
||||
.. function:: get_sdl_version
|
||||
|
||||
| :sl:`get the version number of SDL`
|
||||
| :sg:`get_sdl_version(linked=True) -> major, minor, patch`
|
||||
|
||||
Returns the three version numbers of the SDL library. ``linked=True``
|
||||
will cause the function to return the version of the library that pygame
|
||||
is linked against while ``linked=False`` will cause the function to return
|
||||
the version of the library that pygame is compiled against.
|
||||
It can be used to detect which features may or may not be
|
||||
available through pygame.
|
||||
|
||||
.. versionaddedold:: 1.7.0
|
||||
|
||||
.. versionchanged:: 2.1.4 ``linked`` keyword argument added
|
||||
|
||||
.. ## pygame.get_sdl_version ##
|
||||
|
||||
.. function:: get_sdl_byteorder
|
||||
|
||||
| :sl:`get the byte order of SDL`
|
||||
| :sg:`get_sdl_byteorder() -> int`
|
||||
|
||||
Returns the byte order of the SDL library. It returns ``1234`` for little
|
||||
endian byte order and ``4321`` for big endian byte order.
|
||||
|
||||
.. versionaddedold:: 1.8
|
||||
|
||||
.. ## pygame.get_sdl_byteorder ##
|
||||
|
||||
.. function:: register_quit
|
||||
|
||||
| :sl:`register a function to be called when pygame quits`
|
||||
| :sg:`register_quit(callable, /) -> None`
|
||||
|
||||
When :func:`pygame.quit` is called, all registered quit functions are
|
||||
called. Pygame modules do this automatically when they are initializing, so
|
||||
this function will rarely be needed.
|
||||
|
||||
.. ## pygame.register_quit ##
|
||||
|
||||
.. function:: encode_string
|
||||
|
||||
| :sl:`Encode a Unicode or bytes object`
|
||||
| :sg:`encode_string([obj [, encoding [, errors [, etype]]]]) -> bytes or None`
|
||||
|
||||
obj: If Unicode, encode; if bytes, return unaltered; if anything else,
|
||||
return ``None``; if not given, raise ``SyntaxError``.
|
||||
|
||||
encoding (string): If present, encoding to use. The default is
|
||||
``'unicode_escape'``.
|
||||
|
||||
errors (string): If given, how to handle unencodable characters. The default
|
||||
is ``'backslashreplace'``.
|
||||
|
||||
etype (exception type): If given, the exception type to raise for an
|
||||
encoding error. The default is ``UnicodeEncodeError``, as returned by
|
||||
``PyUnicode_AsEncodedString()``. For the default encoding and errors values
|
||||
there should be no encoding errors.
|
||||
|
||||
This function is used in encoding file paths. Keyword arguments are
|
||||
supported.
|
||||
|
||||
This function is not needed for normal pygame-ce usage.
|
||||
|
||||
.. versionaddedold:: 1.9.2 (primarily for use in unit tests)
|
||||
|
||||
.. ## pygame.encode_string ##
|
||||
|
||||
.. function:: encode_file_path
|
||||
|
||||
| :sl:`Encode a Unicode or bytes object as a file system path`
|
||||
| :sg:`encode_file_path([obj [, etype]]) -> bytes or None`
|
||||
|
||||
obj: If Unicode, encode; if bytes, return unaltered; if anything else,
|
||||
return ``None``; if not given, raise ``SyntaxError``.
|
||||
|
||||
etype (exception type): If given, the exception type to raise for an
|
||||
encoding error. The default is ``UnicodeEncodeError``, as returned by
|
||||
``PyUnicode_AsEncodedString()``.
|
||||
|
||||
This function is used to encode file paths in pygame. Encoding is to the
|
||||
codec as returned by ``sys.getfilesystemencoding()``. Keyword arguments are
|
||||
supported.
|
||||
|
||||
This function is not needed for normal pygame-ce usage.
|
||||
|
||||
.. versionaddedold:: 1.9.2 (primarily for use in unit tests)
|
||||
|
||||
.. ## pygame.encode_file_path ##
|
||||
|
||||
.. function:: print_debug_info
|
||||
|
||||
| :sl:`retrieves useful information for debugging and issue-reporting purposes`
|
||||
| :sg:`print_debug_info(filename=None) -> None`
|
||||
|
||||
Constructs a string containing details on the system, the python interpreter,
|
||||
the pygame version, and the linked and compiled versions of the libraries that
|
||||
pygame wraps. If ``filename`` is ``None``, then the string is printed into the
|
||||
console. Otherwise, the debug string is written to the specified file.
|
||||
|
||||
.. note::
|
||||
If ``pygame.freetype`` has not been initialized with :func:`pygame.init` or :func:`pygame.freetype.init`,
|
||||
then the linked and compiled versions of FreeType will be "Unk" since this information is not
|
||||
available before initialization.
|
||||
|
||||
.. versionadded:: 2.1.4
|
||||
|
||||
.. ## pygame.print_debug_info ##
|
||||
|
||||
|
||||
:mod:`pygame.version`
|
||||
=====================
|
||||
|
||||
.. module:: pygame.version
|
||||
:synopsis: small module containing version information
|
||||
|
||||
| :sl:`small module containing version information`
|
||||
|
||||
This module is automatically imported into the pygame package and can be used to
|
||||
check which version of pygame has been imported.
|
||||
|
||||
.. data:: ver
|
||||
|
||||
| :sl:`version number as a string`
|
||||
| :sg:`ver = '1.2'`
|
||||
|
||||
This is the version represented as a string. It can contain a micro release
|
||||
number as well, e.g. ``'1.5.2'``
|
||||
|
||||
.. ## pygame.version.ver ##
|
||||
|
||||
.. data:: vernum
|
||||
|
||||
| :sl:`tupled integers of the version`
|
||||
| :sg:`vernum = (1, 5, 3)`
|
||||
|
||||
This version information can easily be compared with other version
|
||||
numbers of the same format. An example of checking pygame version numbers
|
||||
would look like this:
|
||||
|
||||
::
|
||||
|
||||
if pygame.version.vernum < (1, 5):
|
||||
print('Warning, older version of pygame (%s)' % pygame.version.ver)
|
||||
disable_advanced_features = True
|
||||
|
||||
.. versionaddedold:: 1.9.6 Attributes ``major``, ``minor``, and ``patch``.
|
||||
|
||||
::
|
||||
|
||||
vernum.major == vernum[0]
|
||||
vernum.minor == vernum[1]
|
||||
vernum.patch == vernum[2]
|
||||
|
||||
.. versionchangedold:: 1.9.6
|
||||
``str(pygame.version.vernum)`` returns a string like ``"2.0.0"`` instead
|
||||
of ``"(2, 0, 0)"``.
|
||||
|
||||
.. versionchangedold:: 1.9.6
|
||||
``repr(pygame.version.vernum)`` returns a string like
|
||||
``"PygameVersion(major=2, minor=0, patch=0)"`` instead of ``"(2, 0, 0)"``.
|
||||
|
||||
.. ## pygame.version.vernum ##
|
||||
|
||||
.. data:: rev
|
||||
|
||||
| :sl:`repository revision of the build`
|
||||
| :sg:`rev = 'a6f89747b551+'`
|
||||
|
||||
The Mercurial node identifier of the repository checkout from which this
|
||||
package was built. If the identifier ends with a plus sign '+' then the
|
||||
package contains uncommitted changes. Please include this revision number
|
||||
in bug reports, especially for non-release pygame builds.
|
||||
|
||||
Important note: pygame development has moved to github, this variable is
|
||||
obsolete now. As soon as development shifted to github, this variable started
|
||||
returning an empty string ``""``.
|
||||
It has always been returning an empty string since ``v1.9.5``.
|
||||
|
||||
.. versionchangedold:: 1.9.5
|
||||
Always returns an empty string ``""``.
|
||||
|
||||
.. ## pygame.version.rev ##
|
||||
|
||||
.. data:: SDL
|
||||
|
||||
| :sl:`tupled integers of the SDL library version`
|
||||
| :sg:`SDL = '(2, 26, 5)'`
|
||||
|
||||
This is the SDL library version represented as an extended tuple. It also has
|
||||
attributes 'major', 'minor' & 'patch' that can be accessed like this:
|
||||
|
||||
::
|
||||
|
||||
>>> pygame.version.SDL.major
|
||||
2
|
||||
|
||||
printing the whole thing returns a string like this:
|
||||
|
||||
::
|
||||
|
||||
>>> pygame.version.SDL
|
||||
SDLVersion(major=2, minor=26, patch=5)
|
||||
|
||||
.. versionaddedold:: 2.0.0
|
||||
|
||||
.. ## pygame.version.SDL ##
|
||||
|
||||
.. ## pygame.version ##
|
||||
|
||||
.. ## pygame ##
|
||||
|
||||
.. _environment-variables:
|
||||
|
||||
**Setting Environment Variables**
|
||||
|
||||
Some aspects of pygame's behaviour can be controlled by setting environment variables, they cover a wide
|
||||
range of the library's functionality. Some of the variables are from pygame itself, while others come from
|
||||
the underlying C SDL library that pygame uses.
|
||||
|
||||
In python, environment variables are usually set in code like this::
|
||||
|
||||
import os
|
||||
os.environ['NAME_OF_ENVIRONMENT_VARIABLE'] = 'value_to_set'
|
||||
|
||||
Or to preserve users ability to override the variable::
|
||||
|
||||
import os
|
||||
os.environ['ENV_VAR'] = os.environ.get('ENV_VAR', 'value')
|
||||
|
||||
If the variable is more useful for users of an app to set than the developer then they can set it like this:
|
||||
|
||||
**Windows**::
|
||||
|
||||
set NAME_OF_ENVIRONMENT_VARIABLE=value_to_set
|
||||
python my_application.py
|
||||
|
||||
**Linux/Mac**::
|
||||
|
||||
ENV_VAR=value python my_application.py
|
||||
|
||||
For some variables they need to be set before initialising pygame, some must be set before even importing pygame,
|
||||
and others can simply be set right before the area of code they control is run.
|
||||
|
||||
Below is a list of environment variables, their settable values, and a brief description of what they do.
|
||||
|
||||
|
|
||||
|
||||
**Pygame Environment Variables**
|
||||
|
||||
These variables are defined by pygame itself.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
PYGAME_DISPLAY - Experimental (subject to change)
|
||||
Set index of the display to use, "0" is the default.
|
||||
|
||||
This sets the display where pygame will open its window
|
||||
or screen. The value set here will be used if set before
|
||||
calling :func:`pygame.display.set_mode()`, and as long as no
|
||||
'display' parameter is passed into :func:`pygame.display.set_mode()`.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
PYGAME_FORCE_SCALE -
|
||||
Set to "photo" or "default".
|
||||
|
||||
This forces set_mode() to use the SCALED display mode and,
|
||||
if "photo" is set, makes the scaling use the slowest, but
|
||||
highest quality anisotropic scaling algorithm, if it is
|
||||
available. Must be set before calling :func:`pygame.display.set_mode()`.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
PYGAME_BLEND_ALPHA_SDL2 - New in pygame 2.0.0
|
||||
Set to "1" to enable the SDL2 blitter.
|
||||
|
||||
This makes pygame use the SDL2 blitter for all alpha
|
||||
blending. The SDL2 blitter is sometimes faster than
|
||||
the default blitter but uses a different formula so
|
||||
the final colors may differ. Must be set before
|
||||
:func:`pygame.init()` is called.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
PYGAME_HIDE_SUPPORT_PROMPT -
|
||||
Set to "1" to hide the prompt.
|
||||
|
||||
This stops the welcome message popping up in the
|
||||
console that tells you which version of python,
|
||||
pygame & SDL you are using. Must be set before
|
||||
importing pygame.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
PYGAME_FREETYPE -
|
||||
Set to "1" to enable.
|
||||
|
||||
This switches the pygame.font module to a pure
|
||||
freetype implementation that bypasses SDL_ttf.
|
||||
See the font module for why you might want to
|
||||
do this. Must be set before importing pygame.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
PYGAME_CAMERA -
|
||||
Set to "opencv"
|
||||
|
||||
Forces the library backend used in the camera
|
||||
module, overriding the platform defaults. Must
|
||||
be set before calling :func:`pygame.camera.init()`.
|
||||
|
||||
In pygame 2.0.3, backends can be set programmatically instead, and the old
|
||||
OpenCV backend has been replaced with one on top of "opencv-python," rather
|
||||
than the old "highgui" OpenCV port. Also, there is a new native Windows
|
||||
backend available.
|
||||
|
||||
|
|
||||
|
|
||||
|
||||
**SDL Environment Variables**
|
||||
|
||||
These variables are defined by SDL.
|
||||
|
||||
For documentation on the environment variables available in
|
||||
pygame 1 try `here
|
||||
<https://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlenvvars.html>`__.
|
||||
For Pygame 2, some selected environment variables are listed below.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
SDL_VIDEO_CENTERED -
|
||||
Set to "1" to enable centering the window.
|
||||
|
||||
This will make the pygame window open in the centre of the display.
|
||||
Must be set before calling :func:`pygame.display.set_mode()`.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
SDL_VIDEO_WINDOW_POS -
|
||||
Set to "x,y" to position the top left corner of the window.
|
||||
|
||||
This allows control over the placement of the pygame window within
|
||||
the display. Must be set before calling :func:`pygame.display.set_mode()`.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
SDL_VIDEODRIVER -
|
||||
Set to "drivername" to change the video driver used.
|
||||
|
||||
On some platforms there are multiple video drivers available and
|
||||
this allows users to pick between them. More information is available
|
||||
`here <https://wiki.libsdl.org/FAQUsingSDL>`__. Must be set before
|
||||
calling :func:`pygame.init()` or :func:`pygame.display.init()`.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
SDL_AUDIODRIVER -
|
||||
Set to "drivername" to change the audio driver used.
|
||||
|
||||
On some platforms there are multiple audio drivers available and
|
||||
this allows users to pick between them. More information is available
|
||||
`here <https://wiki.libsdl.org/FAQUsingSDL>`__. Must be set before
|
||||
calling :func:`pygame.init()` or :func:`pygame.mixer.init()`.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
SDL_VIDEO_ALLOW_SCREENSAVER
|
||||
Set to "1" to allow screensavers while pygame apps are running.
|
||||
|
||||
By default pygame apps disable screensavers while
|
||||
they are running. Setting this environment variable allows users or
|
||||
developers to change that and make screensavers run again.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR
|
||||
Set to "0" to re-enable the compositor.
|
||||
|
||||
By default SDL tries to disable the X11 compositor for all pygame
|
||||
apps. This is usually a good thing as it's faster, however if you
|
||||
have an app which *doesn't* update every frame and are using linux
|
||||
you may want to disable this bypass. The bypass has reported problems
|
||||
on KDE linux. This variable is only used on x11/linux platforms.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS
|
||||
Set to "1" to allow joysticks to be updated even when the window is out of focus
|
||||
|
||||
By default, when the window is not in focus, input devices do not get
|
||||
updated. However, using this environment variable it is possible to get
|
||||
joystick updates even when the window is in the background. Must be set
|
||||
before calling :func:`pygame.init()` or :func:`pygame.joystick.init()`.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
SDL_MOUSE_TOUCH_EVENTS
|
||||
Set to "1" to make mouse events also generate touch events.
|
||||
|
||||
Useful for testing touch events on desktop platforms (e.g. with a trackpad)
|
||||
where this is set to 0 by default.
|
||||
|
||||
|
|
||||
|
||||
::
|
||||
|
||||
"SDL_WINDOWS_DPI_AWARENESS"
|
||||
Set to "permonitorv2" on windows 10 (and later) to declare the pygame
|
||||
window DPI aware and ignore the desktop scaling, "permonitor" for
|
||||
windows 8.1 and later DPI awareness and "system" for windows Vista
|
||||
and later DPI awareness (not per monitor). Finally set it to "unaware",
|
||||
to have the pygame window scale with the desktop scaling.
|
||||
|
||||
This hint only affects the windows platform, other platforms can control DPI awareness
|
||||
via a Window creation keyword parameter called "allow_high_dpi".
|
||||
@@ -0,0 +1,652 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.Rect`
|
||||
==================
|
||||
|
||||
.. currentmodule:: pygame
|
||||
|
||||
.. class:: Rect
|
||||
|
||||
| :sl:`pygame object for storing rectangular coordinates`
|
||||
| :sg:`Rect(left, top, width, height, /) -> Rect`
|
||||
| :sg:`Rect((left, top), (width, height), /) -> Rect`
|
||||
| :sg:`Rect(object, /) -> Rect`
|
||||
| :sg:`Rect() -> Rect`
|
||||
| :sg:`FRect(left, top, width, height, /) -> FRect`
|
||||
| :sg:`FRect((left, top), (width, height), /) -> FRect`
|
||||
| :sg:`FRect(object, /) -> FRect`
|
||||
| :sg:`FRect() -> FRect`
|
||||
|
||||
.. versionadded:: 2.2
|
||||
Added ``FRect`` class that is functionally identical to ``Rect`` but uses
|
||||
floats instead of integers, enabling fractional precision and avoiding
|
||||
truncation error while being interchangeable with standard Rects.
|
||||
|
||||
Pygame uses Rect objects to store and manipulate rectangular areas. A Rect
|
||||
can be created from a combination of left, top, width, and height values.
|
||||
Rects can also be created from python objects that are already a Rect or
|
||||
have an attribute named "rect".
|
||||
|
||||
Any pygame function that requires a Rect argument also accepts any of these
|
||||
values to construct a Rect. This makes it easier to create Rects on the fly
|
||||
as arguments to functions.
|
||||
|
||||
If no arguments are given, a zero Rect will be created (x=0, y=0, w=0, h=0).
|
||||
This will only work when using the Rect/FRect class and not with functions
|
||||
that require a Rect argument.
|
||||
|
||||
The Rect functions that change the position or size of a Rect return a new
|
||||
copy of the Rect with the affected changes. The original Rect is not
|
||||
modified. Some methods have an alternate "in-place" version that returns
|
||||
None but affects the original Rect. These "in-place" methods are denoted
|
||||
with the "ip" suffix.
|
||||
|
||||
The Rect object has several virtual attributes which can be used to move and
|
||||
align the Rect:
|
||||
|
||||
::
|
||||
|
||||
x,y
|
||||
top, left, bottom, right
|
||||
topleft, bottomleft, topright, bottomright
|
||||
midtop, midleft, midbottom, midright
|
||||
center, centerx, centery
|
||||
size, width, height, relcenter
|
||||
w,h
|
||||
|
||||
All of these attributes can be assigned to:
|
||||
|
||||
::
|
||||
|
||||
rect1.right = 10
|
||||
rect2.center = (20,30)
|
||||
|
||||
Assigning to size, width, height, or relcenter changes the dimensions of the rectangle;
|
||||
all other assignments move the rectangle without resizing it. Notice that
|
||||
some attributes are integers and others are pairs of integers.
|
||||
|
||||
If a Rect has a nonzero width or height, it will return ``True`` for a
|
||||
nonzero test. Some methods return a Rect with 0 size to represent an invalid
|
||||
rectangle. A Rect with a 0 size will not collide when using collision
|
||||
detection methods (e.g. :meth:`collidepoint`, :meth:`colliderect`, etc.).
|
||||
|
||||
The coordinates for Rect objects are all integers. The size values can be
|
||||
programmed to have negative values, but these are considered illegal Rects
|
||||
for most operations.
|
||||
|
||||
There are several collision tests between other rectangles. Most python
|
||||
containers can be searched for collisions against a single Rect.
|
||||
|
||||
The area covered by a Rect does not include the right- and bottom-most edge
|
||||
of pixels. If one Rect's bottom border is another Rect's top border (i.e.,
|
||||
rect1.bottom=rect2.top), the two meet exactly on the screen but do not
|
||||
overlap, and ``rect1.colliderect(rect2)`` returns false.
|
||||
|
||||
The Rect object is also iterable:
|
||||
|
||||
::
|
||||
|
||||
r = Rect(0, 1, 2, 3)
|
||||
x, y, w, h = r
|
||||
|
||||
.. versionaddedold:: 1.9.2
|
||||
The Rect class can be subclassed. Methods such as ``copy()`` and ``move()``
|
||||
will recognize this and return instances of the subclass.
|
||||
However, the subclass's ``__init__()`` method is not called,
|
||||
and ``__new__()`` is assumed to take no arguments. So these methods should be
|
||||
overridden if any extra attributes need to be copied.
|
||||
|
||||
.. versionadded:: 2.5.6
|
||||
``relcenter`` added to Rect / FRect. This will return a tuple containing half
|
||||
the Rect's size; the center relative to the topleft of the Rect.
|
||||
Setting it to a ``Point`` will modify the size of the rect to 2 times
|
||||
the ``Point`` given. Below you can find a code example of how it should work:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
>>> my_rect = pygame.Rect(0, 0, 2, 2)
|
||||
>>> my_rect.relcenter
|
||||
(1, 1)
|
||||
>>> my_rect.relcenter = (128, 128)
|
||||
>>> my_rect.size
|
||||
(256, 256)
|
||||
|
||||
Beware of non-integer relative centers! For Rects (but not FRects), ``relcenter``
|
||||
will truncate the numbers in the returned tuple.
|
||||
|
||||
|
||||
.. method:: copy
|
||||
|
||||
| :sl:`copy the rectangle`
|
||||
| :sg:`copy() -> Rect`
|
||||
|
||||
Returns a new rectangle having the same position and size as the original.
|
||||
|
||||
New in pygame 1.9
|
||||
|
||||
.. ## Rect.copy ##
|
||||
|
||||
.. method:: move
|
||||
|
||||
| :sl:`moves the rectangle`
|
||||
| :sg:`move(x, y, /) -> Rect`
|
||||
|
||||
Returns a new rectangle that is moved by the given offset. The x and y
|
||||
arguments can be any integer value, positive or negative.
|
||||
|
||||
.. ## Rect.move ##
|
||||
|
||||
.. method:: move_ip
|
||||
|
||||
| :sl:`moves the rectangle, in place`
|
||||
| :sg:`move_ip(x, y, /) -> None`
|
||||
|
||||
Same as the ``Rect.move()`` method, but operates in place.
|
||||
|
||||
.. ## Rect.move_ip ##
|
||||
|
||||
.. method:: move_to
|
||||
|
||||
| :sl:`moves the rectangle to the specified position`
|
||||
| :sg:`move_to(**kwargs) -> Rect`
|
||||
|
||||
Returns a new rectangle that is moved to the given position and optionally resized.
|
||||
You must provide keyword arguments to the method such as ``center``, ``left``,
|
||||
``midbottom``, ``size`` that correspond to the rectangle's attributes and the
|
||||
method will return a new rectangle whose specified attributes are set to the given value.
|
||||
|
||||
It is similar to :meth:`Surface.get_rect` but instead of a calling it as a surface method
|
||||
you call it as a rectangle method.
|
||||
|
||||
.. versionadded:: 2.4.0
|
||||
|
||||
.. ## Rect.move_to ##
|
||||
|
||||
.. method:: inflate
|
||||
|
||||
| :sl:`grow or shrink the rectangle size`
|
||||
| :sg:`inflate(x, y, /) -> Rect`
|
||||
|
||||
Returns a new rectangle with the size changed by the given offset. The
|
||||
rectangle remains centered around its current center. Negative values
|
||||
will shrink the rectangle. Note, uses integers, if the offset given is
|
||||
too small(< 2 > -2), center will be off.
|
||||
|
||||
.. ## Rect.inflate ##
|
||||
|
||||
.. method:: inflate_ip
|
||||
|
||||
| :sl:`grow or shrink the rectangle size, in place`
|
||||
| :sg:`inflate_ip(x, y, /) -> None`
|
||||
|
||||
Same as the ``Rect.inflate()`` method, but operates in place.
|
||||
|
||||
.. ## Rect.inflate_ip ##
|
||||
|
||||
.. method:: scale_by
|
||||
|
||||
| :sl:`scale the rectangle by given a multiplier`
|
||||
| :sg:`scale_by(scale_by) -> Rect`
|
||||
| :sg:`scale_by(x, y) -> Rect`
|
||||
|
||||
Returns a new rectangle with the size scaled by the given multipliers.
|
||||
The rectangle remains centered around its current center. A single
|
||||
scalar or separate width and height scalars are allowed. Values above
|
||||
one will increase the size of the rectangle, whereas values between
|
||||
zero and one will decrease the size of the rectangle.
|
||||
|
||||
.. versionadded:: 2.3.1
|
||||
|
||||
.. versionchanged:: 2.5.2 the argument ``scale_by`` can now be passed as a positional argument
|
||||
|
||||
.. ## Rect.scale_by ##
|
||||
|
||||
.. method:: scale_by_ip
|
||||
|
||||
| :sl:`grow or shrink the rectangle size, in place`
|
||||
| :sg:`scale_by_ip(scale_by) -> None`
|
||||
| :sg:`scale_by_ip(x, y) -> None`
|
||||
|
||||
Same as the ``Rect.scale_by()`` method, but operates in place.
|
||||
|
||||
.. versionadded:: 2.3.1
|
||||
|
||||
.. versionchanged:: 2.5.2 the argument ``scale_by`` can now be passed as a positional argument
|
||||
|
||||
.. ## Rect.scale_by_ip ##
|
||||
|
||||
.. method:: update
|
||||
|
||||
| :sl:`sets the position and size of the rectangle`
|
||||
| :sg:`update(left, top, width, height, /) -> None`
|
||||
| :sg:`update((left, top), (width, height), /) -> None`
|
||||
| :sg:`update(object, /) -> None`
|
||||
|
||||
Sets the position and size of the rectangle, in place. See
|
||||
parameters for :meth:`pygame.Rect` for the parameters of this function.
|
||||
|
||||
.. versionaddedold:: 2.0.1
|
||||
|
||||
.. ## Rect.update ##
|
||||
|
||||
.. method:: clamp
|
||||
|
||||
| :sl:`moves the rectangle inside another`
|
||||
| :sg:`clamp(rect, /) -> Rect`
|
||||
|
||||
Returns a new rectangle that is moved to be completely inside the
|
||||
argument Rect. If the rectangle is too large to fit inside, it is
|
||||
centered inside the argument Rect, but its size is not changed.
|
||||
|
||||
.. ## Rect.clamp ##
|
||||
|
||||
.. method:: clamp_ip
|
||||
|
||||
| :sl:`moves the rectangle inside another, in place`
|
||||
| :sg:`clamp_ip(rect, /) -> None`
|
||||
|
||||
Same as the ``Rect.clamp()`` method, but operates in place.
|
||||
|
||||
.. ## Rect.clamp_ip ##
|
||||
|
||||
.. method:: clip
|
||||
|
||||
| :sl:`crops a rectangle inside another`
|
||||
| :sg:`clip(rect, /) -> Rect`
|
||||
|
||||
Returns a new rectangle that is cropped to be completely inside the
|
||||
argument Rect. If the two rectangles do not overlap to begin with, a Rect
|
||||
with 0 size is returned.
|
||||
|
||||
.. ## Rect.clip ##
|
||||
|
||||
.. method:: clipline
|
||||
|
||||
| :sl:`crops a line inside a rectangle`
|
||||
| :sg:`clipline(x1, y1, x2, y2, /) -> ((cx1, cy1), (cx2, cy2))`
|
||||
| :sg:`clipline(x1, y1, x2, y2, /) -> ()`
|
||||
| :sg:`clipline((x1, y1), (x2, y2), /) -> ((cx1, cy1), (cx2, cy2))`
|
||||
| :sg:`clipline((x1, y1), (x2, y2), /) -> ()`
|
||||
| :sg:`clipline((x1, y1, x2, y2), /) -> ((cx1, cy1), (cx2, cy2))`
|
||||
| :sg:`clipline((x1, y1, x2, y2), /) -> ()`
|
||||
| :sg:`clipline(((x1, y1), (x2, y2)), /) -> ((cx1, cy1), (cx2, cy2))`
|
||||
| :sg:`clipline(((x1, y1), (x2, y2)), /) -> ()`
|
||||
|
||||
Returns the coordinates of a line that is cropped to be completely inside
|
||||
the rectangle. If the line does not overlap the rectangle, then an empty
|
||||
tuple is returned.
|
||||
|
||||
The line to crop can be any of the following formats (floats can be used
|
||||
in place of ints, but they will be truncated):
|
||||
|
||||
- four ints
|
||||
- 2 lists/tuples/Vector2s of 2 ints
|
||||
- a list/tuple of four ints
|
||||
- a list/tuple of 2 lists/tuples/Vector2s of 2 ints
|
||||
|
||||
:returns: a tuple with the coordinates of the given line cropped to be
|
||||
completely inside the rectangle is returned, if the given line does
|
||||
not overlap the rectangle, an empty tuple is returned
|
||||
:rtype: tuple(tuple(int, int), tuple(int, int)) or ()
|
||||
|
||||
:raises TypeError: if the line coordinates are not given as one of the
|
||||
above described line formats
|
||||
|
||||
.. note ::
|
||||
This method can be used for collision detection between a rect and a
|
||||
line. See example code below.
|
||||
|
||||
.. note ::
|
||||
The ``rect.bottom`` and ``rect.right`` attributes of a
|
||||
:mod:`pygame.Rect` always lie one pixel outside of its actual border.
|
||||
|
||||
::
|
||||
|
||||
# Example using clipline().
|
||||
clipped_line = rect.clipline(line)
|
||||
|
||||
if clipped_line:
|
||||
# If clipped_line is not an empty tuple then the line
|
||||
# collides/overlaps with the rect. The returned value contains
|
||||
# the endpoints of the clipped line.
|
||||
start, end = clipped_line
|
||||
x1, y1 = start
|
||||
x2, y2 = end
|
||||
else:
|
||||
print("No clipping. The line is fully outside the rect.")
|
||||
|
||||
.. versionaddedold:: 2.0.0
|
||||
|
||||
.. ## Rect.clipline ##
|
||||
|
||||
.. method:: union
|
||||
|
||||
| :sl:`joins two rectangles into one`
|
||||
| :sg:`union(rect, /) -> Rect`
|
||||
|
||||
Returns a new rectangle that completely covers the area of the two
|
||||
provided rectangles. There may be area inside the new Rect that is not
|
||||
covered by the originals.
|
||||
|
||||
.. ## Rect.union ##
|
||||
|
||||
.. method:: union_ip
|
||||
|
||||
| :sl:`joins two rectangles into one, in place`
|
||||
| :sg:`union_ip(rect, /) -> None`
|
||||
|
||||
Same as the ``Rect.union()`` method, but operates in place.
|
||||
|
||||
.. ## Rect.union_ip ##
|
||||
|
||||
.. method:: unionall
|
||||
|
||||
| :sl:`the union of many rectangles`
|
||||
| :sg:`unionall(rect_sequence, /) -> Rect`
|
||||
|
||||
Returns the union of one rectangle with a sequence of many rectangles.
|
||||
|
||||
.. ## Rect.unionall ##
|
||||
|
||||
.. method:: unionall_ip
|
||||
|
||||
| :sl:`the union of many rectangles, in place`
|
||||
| :sg:`unionall_ip(rect_sequence, /) -> None`
|
||||
|
||||
The same as the ``Rect.unionall()`` method, but operates in place.
|
||||
|
||||
.. ## Rect.unionall_ip ##
|
||||
|
||||
.. method:: fit
|
||||
|
||||
| :sl:`resize and move a rectangle with aspect ratio`
|
||||
| :sg:`fit(rect, /) -> Rect`
|
||||
|
||||
Returns a new rectangle that is moved and resized to fit another. The
|
||||
aspect ratio of the original Rect is preserved, so the new rectangle may
|
||||
be smaller than the target in either width or height.
|
||||
|
||||
.. ## Rect.fit ##
|
||||
|
||||
.. method:: normalize
|
||||
|
||||
| :sl:`correct negative sizes`
|
||||
| :sg:`normalize() -> None`
|
||||
|
||||
This will flip the width or height of a rectangle if it has a negative
|
||||
size. The rectangle will remain in the same place, with only the sides
|
||||
swapped.
|
||||
|
||||
.. ## Rect.normalize ##
|
||||
|
||||
.. method:: contains
|
||||
|
||||
| :sl:`test if one rectangle is inside another`
|
||||
| :sg:`contains(rect, /) -> bool`
|
||||
|
||||
Returns true when the argument is completely inside the Rect.
|
||||
|
||||
.. ## Rect.contains ##
|
||||
|
||||
.. method:: collidepoint
|
||||
|
||||
| :sl:`test if a point is inside a rectangle`
|
||||
| :sg:`collidepoint(x, y, /) -> bool`
|
||||
| :sg:`collidepoint((x, y), /) -> bool`
|
||||
|
||||
Returns true if the given point is inside the rectangle. A point along
|
||||
the right or bottom edge is not considered to be inside the rectangle.
|
||||
|
||||
.. note ::
|
||||
For collision detection between a rect and a line the :meth:`clipline`
|
||||
method can be used.
|
||||
|
||||
.. ## Rect.collidepoint ##
|
||||
|
||||
.. method:: colliderect
|
||||
|
||||
| :sl:`test if two rectangles overlap`
|
||||
| :sg:`colliderect(rect, /) -> bool`
|
||||
|
||||
Returns true if any portion of either rectangle overlap (except the
|
||||
top+bottom or left+right edges).
|
||||
|
||||
.. note ::
|
||||
For collision detection between a rect and a line the :meth:`clipline`
|
||||
method can be used.
|
||||
|
||||
.. ## Rect.colliderect ##
|
||||
|
||||
.. method:: collidelist
|
||||
|
||||
| :sl:`test if one rectangle in a list intersects`
|
||||
| :sg:`collidelist(list, /) -> index`
|
||||
|
||||
Test whether the rectangle collides with any in a sequence of rectangles.
|
||||
The index of the first collision found is returned. If no collisions are
|
||||
found an index of -1 is returned.
|
||||
|
||||
.. ## Rect.collidelist ##
|
||||
|
||||
.. method:: collidelistall
|
||||
|
||||
| :sl:`test if all rectangles in a list intersect`
|
||||
| :sg:`collidelistall(list, /) -> indices`
|
||||
|
||||
Returns a list of all the indices that contain rectangles that collide
|
||||
with the Rect. If no intersecting rectangles are found, an empty list is
|
||||
returned.
|
||||
|
||||
Not only Rects are valid arguments, but these are all valid calls:
|
||||
|
||||
.. code-block:: python
|
||||
:linenos:
|
||||
|
||||
Rect = pygame.Rect
|
||||
r = Rect(0, 0, 10, 10)
|
||||
|
||||
list_of_rects = [Rect(1, 1, 1, 1), Rect(2, 2, 2, 2)]
|
||||
indices0 = r.collidelistall(list_of_rects)
|
||||
|
||||
list_of_lists = [[1, 1, 1, 1], [2, 2, 2, 2]]
|
||||
indices1 = r.collidelistall(list_of_lists)
|
||||
|
||||
list_of_tuples = [(1, 1, 1, 1), (2, 2, 2, 2)]
|
||||
indices2 = r.collidelistall(list_of_tuples)
|
||||
|
||||
list_of_double_tuples = [((1, 1), (1, 1)), ((2, 2), (2, 2))]
|
||||
indices3 = r.collidelistall(list_of_double_tuples)
|
||||
|
||||
class ObjectWithRectAttribute(object):
|
||||
def __init__(self, r):
|
||||
self.rect = r
|
||||
|
||||
list_of_object_with_rect_attribute = [
|
||||
ObjectWithRectAttribute(Rect(1, 1, 1, 1)),
|
||||
ObjectWithRectAttribute(Rect(2, 2, 2, 2)),
|
||||
]
|
||||
indices4 = r.collidelistall(list_of_object_with_rect_attribute)
|
||||
|
||||
class ObjectWithCallableRectAttribute(object):
|
||||
def __init__(self, r):
|
||||
self._rect = r
|
||||
|
||||
def rect(self):
|
||||
return self._rect
|
||||
|
||||
list_of_object_with_callable_rect = [
|
||||
ObjectWithCallableRectAttribute(Rect(1, 1, 1, 1)),
|
||||
ObjectWithCallableRectAttribute(Rect(2, 2, 2, 2)),
|
||||
]
|
||||
indices5 = r.collidelistall(list_of_object_with_callable_rect)
|
||||
|
||||
|
||||
.. ## Rect.collidelistall ##
|
||||
|
||||
.. method:: collideobjects
|
||||
|
||||
| :sl:`test if any object in a list intersects`
|
||||
| :sg:`collideobjects(rect_list) -> object`
|
||||
| :sg:`collideobjects(obj_list, key=func) -> object`
|
||||
|
||||
Test whether the rectangle collides with any object in the sequence.
|
||||
The object of the first collision found is returned. If no collisions are
|
||||
found then ``None`` is returned
|
||||
|
||||
If key is given, then it should be a method taking an object from the list
|
||||
as input and returning a rect like object e.g. ``lambda obj: obj.rectangle``.
|
||||
If an object has multiple attributes of type Rect then key could return one
|
||||
of them.
|
||||
|
||||
.. code-block:: python
|
||||
:linenos:
|
||||
|
||||
r = Rect(1, 1, 10, 10)
|
||||
|
||||
rects = [
|
||||
Rect(1, 1, 10, 10),
|
||||
Rect(5, 5, 10, 10),
|
||||
Rect(15, 15, 1, 1),
|
||||
Rect(2, 2, 1, 1),
|
||||
]
|
||||
|
||||
result = r.collideobjects(rects) # -> <rect(1, 1, 10, 10)>
|
||||
print(result)
|
||||
|
||||
class ObjectWithSomRectAttribute:
|
||||
def __init__(self, name, collision_box, draw_rect):
|
||||
self.name = name
|
||||
self.draw_rect = draw_rect
|
||||
self.collision_box = collision_box
|
||||
|
||||
def __repr__(self):
|
||||
return f'<{self.__class__.__name__}("{self.name}", {list(self.collision_box)}, {list(self.draw_rect)})>'
|
||||
|
||||
objects = [
|
||||
ObjectWithSomRectAttribute("A", Rect(15, 15, 1, 1), Rect(150, 150, 50, 50)),
|
||||
ObjectWithSomRectAttribute("B", Rect(1, 1, 10, 10), Rect(300, 300, 50, 50)),
|
||||
ObjectWithSomRectAttribute("C", Rect(5, 5, 10, 10), Rect(200, 500, 50, 50)),
|
||||
]
|
||||
|
||||
# collision = r.collideobjects(objects) # this does not work because the items in the list are no Rect like object
|
||||
collision = r.collideobjects(
|
||||
objects, key=lambda o: o.collision_box
|
||||
) # -> <ObjectWithSomRectAttribute("B", [1, 1, 10, 10], [300, 300, 50, 50])>
|
||||
print(collision)
|
||||
|
||||
screen_rect = r.collideobjects(objects, key=lambda o: o.draw_rect) # -> None
|
||||
print(screen_rect)
|
||||
|
||||
.. versionadded:: 2.1.3
|
||||
|
||||
.. ## Rect.collideobjects ##
|
||||
|
||||
.. method:: collideobjectsall
|
||||
|
||||
| :sl:`test if all objects in a list intersect`
|
||||
| :sg:`collideobjectsall(rect_list) -> objects`
|
||||
| :sg:`collideobjectsall(obj_list, key=func) -> objects`
|
||||
|
||||
Returns a list of all the objects that contain rectangles that collide
|
||||
with the Rect. If no intersecting objects are found, an empty list is
|
||||
returned.
|
||||
|
||||
If key is given, then it should be a method taking an object from the list
|
||||
as input and returning a rect like object e.g. ``lambda obj: obj.rectangle``.
|
||||
If an object has multiple attributes of type Rect then key could return one
|
||||
of them.
|
||||
|
||||
.. code-block:: python
|
||||
:linenos:
|
||||
|
||||
r = Rect(1, 1, 10, 10)
|
||||
|
||||
rects = [
|
||||
Rect(1, 1, 10, 10),
|
||||
Rect(5, 5, 10, 10),
|
||||
Rect(15, 15, 1, 1),
|
||||
Rect(2, 2, 1, 1),
|
||||
]
|
||||
|
||||
result = r.collideobjectsall(
|
||||
rects
|
||||
) # -> [<rect(1, 1, 10, 10)>, <rect(5, 5, 10, 10)>, <rect(2, 2, 1, 1)>]
|
||||
print(result)
|
||||
|
||||
class ObjectWithSomRectAttribute:
|
||||
def __init__(self, name, collision_box, draw_rect):
|
||||
self.name = name
|
||||
self.draw_rect = draw_rect
|
||||
self.collision_box = collision_box
|
||||
|
||||
def __repr__(self):
|
||||
return f'<{self.__class__.__name__}("{self.name}", {list(self.collision_box)}, {list(self.draw_rect)})>'
|
||||
|
||||
objects = [
|
||||
ObjectWithSomRectAttribute("A", Rect(1, 1, 10, 10), Rect(300, 300, 50, 50)),
|
||||
ObjectWithSomRectAttribute("B", Rect(5, 5, 10, 10), Rect(200, 500, 50, 50)),
|
||||
ObjectWithSomRectAttribute("C", Rect(15, 15, 1, 1), Rect(150, 150, 50, 50)),
|
||||
]
|
||||
|
||||
# collisions = r.collideobjectsall(objects) # this does not work because ObjectWithSomRectAttribute is not a Rect like object
|
||||
collisions = r.collideobjectsall(
|
||||
objects, key=lambda o: o.collision_box
|
||||
) # -> [<ObjectWithSomRectAttribute("A", [1, 1, 10, 10], [300, 300, 50, 50])>, <ObjectWithSomRectAttribute("B", [5, 5, 10, 10], [200, 500, 50, 50])>]
|
||||
print(collisions)
|
||||
|
||||
screen_rects = r.collideobjectsall(objects, key=lambda o: o.draw_rect) # -> []
|
||||
print(screen_rects)
|
||||
|
||||
.. versionadded:: 2.1.3
|
||||
|
||||
.. ## Rect.collideobjectsall ##
|
||||
|
||||
.. method:: collidedict
|
||||
|
||||
| :sl:`test if one rectangle in a dictionary intersects`
|
||||
| :sg:`collidedict(rect_dict) -> (key, value)`
|
||||
| :sg:`collidedict(rect_dict) -> None`
|
||||
| :sg:`collidedict(rect_dict, values=False) -> (key, value)`
|
||||
| :sg:`collidedict(rect_dict, values=False) -> None`
|
||||
|
||||
Returns the first key and value pair that intersects with the calling
|
||||
Rect object. If no collisions are found, ``None`` is returned. If
|
||||
``values`` is False (default) then the dict's keys will be used in the
|
||||
collision detection, otherwise the dict's values will be used.
|
||||
|
||||
.. note ::
|
||||
Rect objects cannot be used as keys in a dictionary (they are not
|
||||
hashable), so they must be converted to a tuple.
|
||||
e.g. ``rect.collidedict({tuple(key_rect) : value})``
|
||||
|
||||
.. versionchanged:: 2.4.0
|
||||
``values`` is now accepted as a keyword argument. Type Stub updated
|
||||
to use boolean ``True`` or ``False``, but any truthy or falsy value
|
||||
will be valid.
|
||||
|
||||
.. ## Rect.collidedict ##
|
||||
|
||||
.. method:: collidedictall
|
||||
|
||||
| :sl:`test if all rectangles in a dictionary intersect`
|
||||
| :sg:`collidedictall(rect_dict) -> [(key, value), ...]`
|
||||
| :sg:`collidedictall(rect_dict, values=False) -> [(key, value), ...]`
|
||||
|
||||
Returns a list of all the key and value pairs that intersect with the
|
||||
calling Rect object. If no collisions are found an empty list is returned.
|
||||
If ``values`` is False (default) then the dict's keys will be used in the
|
||||
collision detection, otherwise the dict's values will be used.
|
||||
|
||||
.. note ::
|
||||
Rect objects cannot be used as keys in a dictionary (they are not
|
||||
hashable), so they must be converted to a tuple.
|
||||
e.g. ``rect.collidedictall({tuple(key_rect) : value})``
|
||||
|
||||
.. versionchanged:: 2.4.0
|
||||
``values`` is now accepted as a keyword argument. Type Stub updated
|
||||
to use boolean ``True`` or ``False``, but any truthy or falsy value
|
||||
will be valid.
|
||||
|
||||
.. ## Rect.collidedictall ##
|
||||
|
||||
.. ## pygame.Rect ##
|
||||
@@ -0,0 +1,227 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.scrap`
|
||||
===================
|
||||
|
||||
.. autopgmodule:: pygame.scrap
|
||||
:members:
|
||||
|
||||
**THE BELOW INFORMATION IS DEPRECATED IN PYGAME 2.2.0 AND WILL BE REMOVED IN THE FUTURE.**
|
||||
|
||||
The scrap module is for transferring data to/from the clipboard. This allows
|
||||
for cutting and pasting data between pygame and other applications. Some basic
|
||||
data (MIME) types are defined and registered:
|
||||
|
||||
::
|
||||
|
||||
"text/plain" Plain text (also accessible via the SCRAP_TEXT constant)
|
||||
"text/plain;charset=utf-8" UTF-8 encoded text
|
||||
|
||||
For **Windows** platforms, these additional types are supported automatically
|
||||
and resolve to their internal definitions:
|
||||
|
||||
::
|
||||
|
||||
"image/bmp" BMP encoded image data (also accessible via the SCRAP_BMP constant)
|
||||
"audio/wav" WAV encoded audio
|
||||
"image/tiff" TIFF encoded image data
|
||||
|
||||
|
||||
User defined types can be used on **Windows**, but the data might not be
|
||||
accessible by other applications unless they know what data type to look for.
|
||||
Example: Data placed into the clipboard by
|
||||
``pygame.scrap.put("my_data_type", byte_data)`` can only be accessed by
|
||||
applications which query the clipboard for the ``"my_data_type"`` data type.
|
||||
|
||||
For an example of how the scrap module works refer to the examples page
|
||||
(:func:`pygame.examples.scrap_clipboard.main`) or the code directly in GitHub
|
||||
(`pygame/examples/scrap_clipboard.py <https://github.com/pygame-community/pygame-ce/blob/main/examples/scrap_clipboard.py>`_).
|
||||
|
||||
.. versionaddedold:: 1.8
|
||||
|
||||
.. note::
|
||||
Non-text data is only supported on Windows. On other platforms only text is supported.
|
||||
|
||||
.. function:: init
|
||||
|
||||
| :sl:`Initializes the scrap module.`
|
||||
| :sg:`init() -> None`
|
||||
|
||||
Initialize the scrap module.
|
||||
|
||||
:raises pygame.error: if unable to initialize scrap module
|
||||
|
||||
.. note:: The scrap module requires :func:`pygame.display.set_mode()` be
|
||||
called before being initialized.
|
||||
|
||||
.. deprecated:: 2.2.0
|
||||
|
||||
.. ## pygame.scrap.init ##
|
||||
|
||||
.. function:: get_init
|
||||
|
||||
| :sl:`Returns True if the scrap module is currently initialized.`
|
||||
| :sg:`get_init() -> bool`
|
||||
|
||||
Gets the scrap module's initialization state.
|
||||
|
||||
:returns: ``True`` if the :mod:`pygame.scrap` module is currently
|
||||
initialized, ``False`` otherwise
|
||||
:rtype: bool
|
||||
|
||||
.. versionaddedold:: 1.9.5
|
||||
.. deprecated:: 2.2.0
|
||||
|
||||
.. ## pygame.scrap.get_init ##
|
||||
|
||||
.. function:: get
|
||||
|
||||
| :sl:`Gets the data for the specified type from the clipboard.`
|
||||
| :sg:`get(type, /) -> bytes | None`
|
||||
|
||||
Retrieves the data for the specified type from the clipboard. The data is
|
||||
returned as a byte string and might need further processing (such as
|
||||
decoding to Unicode).
|
||||
|
||||
:param string type: data type to retrieve from the clipboard
|
||||
|
||||
:returns: data (bytes object) for the given type identifier or ``None`` if
|
||||
no data for the given type is available
|
||||
:rtype: bytes | None
|
||||
|
||||
.. deprecated:: 2.2.0
|
||||
|
||||
::
|
||||
|
||||
text = pygame.scrap.get(pygame.SCRAP_TEXT)
|
||||
if text:
|
||||
print("There is text in the clipboard.")
|
||||
else:
|
||||
print("There does not seem to be text in the clipboard.")
|
||||
|
||||
.. ## pygame.scrap.get ##
|
||||
|
||||
.. function:: get_types
|
||||
|
||||
| :sl:`Gets a list of the available clipboard types.`
|
||||
| :sg:`get_types() -> list`
|
||||
|
||||
Gets a list of data type string identifiers for the data currently
|
||||
available on the clipboard. Each identifier can be used in the
|
||||
:func:`pygame.scrap.get()` method to get the clipboard content of the
|
||||
specific type.
|
||||
|
||||
:returns: list of strings of the available clipboard data types, if there
|
||||
is no data in the clipboard an empty list is returned
|
||||
:rtype: list
|
||||
|
||||
.. deprecated:: 2.2.0
|
||||
|
||||
::
|
||||
|
||||
for t in pygame.scrap.get_types():
|
||||
if "text" in t:
|
||||
# There is some content with the word "text" in its type string.
|
||||
print(pygame.scrap.get(t))
|
||||
|
||||
.. ## pygame.scrap.get_types ##
|
||||
|
||||
.. function:: put
|
||||
|
||||
| :sl:`Places data into the clipboard.`
|
||||
| :sg:`put(type, data, /) -> None`
|
||||
|
||||
Places data for a given clipboard type into the clipboard. The data must
|
||||
be a string buffer. The type is a string identifying the type of data to be
|
||||
placed into the clipboard. This can be one of the predefined
|
||||
``pygame.SCRAP_BMP`` or ``pygame.SCRAP_TEXT`` values or a user defined
|
||||
string identifier.
|
||||
|
||||
:param string type: type identifier of the data to be placed into the
|
||||
clipboard
|
||||
:param data: data to be place into the clipboard, a bytes object
|
||||
:type data: bytes
|
||||
|
||||
:raises pygame.error: if unable to put the data into the clipboard
|
||||
|
||||
.. deprecated:: 2.2.0
|
||||
|
||||
::
|
||||
|
||||
with open("example.bmp", "rb") as fp:
|
||||
pygame.scrap.put(pygame.SCRAP_BMP, fp.read())
|
||||
# The image data is now on the clipboard for other applications to access
|
||||
# it.
|
||||
pygame.scrap.put(pygame.SCRAP_TEXT, b"A text to copy")
|
||||
pygame.scrap.put("Plain text", b"Data for user defined type 'Plain text'")
|
||||
|
||||
.. ## pygame.scrap.put ##
|
||||
|
||||
.. function:: contains
|
||||
|
||||
| :sl:`Checks whether data for a given type is available in the clipboard.`
|
||||
| :sg:`contains(type, /) -> bool`
|
||||
|
||||
Checks whether data for the given type is currently available in the
|
||||
clipboard.
|
||||
|
||||
:param string type: data type to check availability of
|
||||
|
||||
:returns: ``True`` if data for the passed type is available in the
|
||||
clipboard, ``False`` otherwise
|
||||
:rtype: bool
|
||||
|
||||
.. deprecated:: 2.2.0
|
||||
|
||||
::
|
||||
|
||||
if pygame.scrap.contains(pygame.SCRAP_TEXT):
|
||||
print("There is text in the clipboard.")
|
||||
if pygame.scrap.contains("own_data_type"):
|
||||
print("There is stuff in the clipboard.")
|
||||
|
||||
.. ## pygame.scrap.contains ##
|
||||
|
||||
.. function:: lost
|
||||
|
||||
| :sl:`Indicates if the clipboard ownership has been lost by the pygame application.`
|
||||
| :sg:`lost() -> bool`
|
||||
|
||||
Indicates if the clipboard ownership has been lost by the pygame
|
||||
application.
|
||||
|
||||
:returns: ``True``, if the clipboard ownership has been lost by the pygame
|
||||
application, ``False`` if the pygame application still owns the clipboard
|
||||
:rtype: bool
|
||||
|
||||
.. deprecated:: 2.2.0
|
||||
|
||||
::
|
||||
|
||||
if pygame.scrap.lost():
|
||||
print("The clipboard is in use by another application.")
|
||||
|
||||
.. ## pygame.scrap.lost ##
|
||||
|
||||
.. function:: set_mode
|
||||
|
||||
| :sl:`Sets the clipboard access mode.`
|
||||
| :sg:`set_mode(mode, /) -> None`
|
||||
|
||||
Sets the access mode for the clipboard. This is only of interest for X11
|
||||
environments where clipboard modes ``pygame.SCRAP_SELECTION`` (for mouse
|
||||
selections) and ``pygame.SCRAP_CLIPBOARD`` (for the clipboard) are
|
||||
available. Setting the mode to ``pygame.SCRAP_SELECTION`` in other
|
||||
environments will not change the mode from ``pygame.SCRAP_CLIPBOARD``.
|
||||
|
||||
:param mode: access mode, supported values are ``pygame.SCRAP_CLIPBOARD``
|
||||
and ``pygame.SCRAP_SELECTION`` (``pygame.SCRAP_SELECTION`` only has an
|
||||
effect when used on X11 platforms)
|
||||
|
||||
:raises ValueError: if the ``mode`` parameter is not
|
||||
``pygame.SCRAP_CLIPBOARD`` or ``pygame.SCRAP_SELECTION``
|
||||
|
||||
.. deprecated:: 2.2.0
|
||||
|
||||
.. ## pygame.scrap.set_mode ##
|
||||
.. ## pygame.scrap ##
|
||||
@@ -0,0 +1,307 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame._sdl2.controller`
|
||||
==============================
|
||||
|
||||
.. module:: pygame._sdl2.controller
|
||||
:synopsis: pygame module to work with controllers
|
||||
|
||||
| :sl:`Pygame module to work with controllers.`
|
||||
|
||||
This module offers control over common controller types like the dualshock 4 or
|
||||
the xbox 360 controllers: They have two analog sticks, two triggers, two shoulder buttons,
|
||||
a dpad, 4 buttons on the side, 2 (or 3) buttons in the middle.
|
||||
|
||||
Pygame uses xbox controllers naming conventions (like a, b, x, y for buttons) but
|
||||
they always refer to the same buttons. For example ``CONTROLLER_BUTTON_X`` is
|
||||
always the leftmost button of the 4 buttons on the right.
|
||||
|
||||
Controllers can generate the following events::
|
||||
|
||||
CONTROLLERAXISMOTION, CONTROLLERBUTTONDOWN, CONTROLLERBUTTONUP,
|
||||
CONTROLLERDEVICEREMAPPED, CONTROLLERDEVICEADDED, CONTROLLERDEVICEREMOVED,
|
||||
CONTROLLERTOUCHPADDOWN, CONTROLLERTOUCHPADMOTION, CONTROLLERTOUCHPADUP
|
||||
|
||||
These events can be enabled/disabled by :meth:`pygame._sdl2.controller.set_eventstate`
|
||||
Note that controllers can generate joystick events as well. This function only toggles
|
||||
events related to controllers.
|
||||
|
||||
.. note::
|
||||
See the :mod:`pygame.joystick` for a more versatile but more advanced api.
|
||||
|
||||
.. versionaddedold:: 2 This module requires SDL2.
|
||||
|
||||
.. function:: init
|
||||
|
||||
| :sl:`initialize the controller module`
|
||||
| :sg:`init() -> None`
|
||||
|
||||
Initialize the controller module.
|
||||
|
||||
.. ## pygame._sdl2.controller.init ##
|
||||
|
||||
.. function:: quit
|
||||
|
||||
| :sl:`Uninitialize the controller module.`
|
||||
| :sg:`quit() -> None`
|
||||
|
||||
Uninitialize the controller module.
|
||||
|
||||
.. ## pygame._sdl2.controller.quit ##
|
||||
|
||||
.. function:: get_init
|
||||
|
||||
| :sl:`Returns True if the controller module is initialized.`
|
||||
| :sg:`get_init() -> bool`
|
||||
|
||||
Test if ``pygame._sdl2.controller.init()`` was called.
|
||||
|
||||
.. ## pygame._sdl2.controller.get_init ##
|
||||
|
||||
.. function:: set_eventstate
|
||||
|
||||
| :sl:`Sets the current state of events related to controllers`
|
||||
| :sg:`set_eventstate(state) -> None`
|
||||
|
||||
Enable or disable events connected to controllers.
|
||||
|
||||
.. note::
|
||||
Controllers can still generate joystick events, which will not be toggled by this function.
|
||||
|
||||
.. versionchangedold:: 2.0.2: Changed return type from int to None
|
||||
|
||||
.. ## pygame._sdl2.controller.set_eventstate ##
|
||||
|
||||
.. function:: get_eventstate
|
||||
|
||||
| :sl:`Gets the current state of events related to controllers`
|
||||
| :sg:`get_eventstate() -> bool`
|
||||
|
||||
Returns the current state of events related to controllers, True meaning
|
||||
events will be posted.
|
||||
|
||||
.. versionaddedold:: 2.0.2
|
||||
|
||||
.. ## pygame._sdl2.controller.get_eventstate ##
|
||||
|
||||
.. function:: get_count
|
||||
|
||||
| :sl:`Get the number of joysticks connected`
|
||||
| :sg:`get_count() -> int`
|
||||
|
||||
Get the number of joysticks connected.
|
||||
|
||||
.. ## pygame._sdl2.controller.get_count ##
|
||||
|
||||
.. function:: is_controller
|
||||
|
||||
| :sl:`Check if the given joystick is supported by the game controller interface`
|
||||
| :sg:`is_controller(index) -> bool`
|
||||
|
||||
Returns True if the index given can be used to create a controller object.
|
||||
|
||||
.. ## pygame._sdl2.controller.is_controller ##
|
||||
|
||||
.. function:: name_forindex
|
||||
|
||||
| :sl:`Get the name of the controller`
|
||||
| :sg:`name_forindex(index) -> name or None`
|
||||
|
||||
Returns the name of controller, or None if there's no name or the
|
||||
index is invalid.
|
||||
|
||||
.. ## pygame._sdl2.controller.name_forindex ##
|
||||
|
||||
.. class:: Controller
|
||||
|
||||
| :sl:`Create a new Controller object.`
|
||||
| :sg:`Controller(index) -> Controller`
|
||||
|
||||
Create a new Controller object. Index should be integer between
|
||||
0 and ``pygame._sdl2.controller.get_count()``. Controllers also
|
||||
can be created from a ``pygame.joystick.Joystick`` using
|
||||
``pygame._sdl2.controller.from_joystick``. Controllers are
|
||||
initialized on creation.
|
||||
|
||||
.. method:: init
|
||||
|
||||
| :sl:`Initialize the Controller`
|
||||
| :sg:`init() -> None`
|
||||
|
||||
Initialize a controller object. This should not be used much, since
|
||||
Controllers are initialised on creation.
|
||||
|
||||
.. method:: quit
|
||||
|
||||
| :sl:`uninitialize the Controller`
|
||||
| :sg:`quit() -> None`
|
||||
|
||||
Close a Controller object. After this the pygame event queue will no longer
|
||||
receive events from the device.
|
||||
|
||||
It is safe to call this more than once.
|
||||
|
||||
.. ## Controller.quit ##
|
||||
|
||||
.. method:: get_init
|
||||
|
||||
| :sl:`check if the Controller is initialized`
|
||||
| :sg:`get_init() -> bool`
|
||||
|
||||
Returns True if the Controller object is currently initialised.
|
||||
|
||||
.. ## Controller.get_init ##
|
||||
|
||||
.. staticmethod:: from_joystick
|
||||
|
||||
| :sl:`Create a Controller from a pygame.joystick.Joystick object`
|
||||
| :sg:`from_joystick(joystick) -> Controller`
|
||||
|
||||
Create a Controller object from a ``pygame.joystick.Joystick`` object
|
||||
|
||||
.. ## Controller.from_joystick ##
|
||||
|
||||
.. method:: attached
|
||||
|
||||
| :sl:`Check if the Controller has been opened and is currently connected.`
|
||||
| :sg:`attached() -> bool`
|
||||
|
||||
Returns True if the Controller object is opened and connected.
|
||||
|
||||
.. ## Controller.attached ##
|
||||
|
||||
.. method:: as_joystick
|
||||
|
||||
| :sl:`Returns a pygame.joystick.Joystick() object`
|
||||
| :sg:`as_joystick() -> Joystick object`
|
||||
|
||||
Returns a pygame.joystick.Joystick() object created from this controller's index
|
||||
|
||||
.. ## Controller.as_joystick ##
|
||||
|
||||
.. method:: get_axis
|
||||
|
||||
| :sl:`Get the current state of a joystick axis`
|
||||
| :sg:`get_axis(axis) -> int`
|
||||
|
||||
Get the current state of a trigger or joystick axis.
|
||||
The axis argument must be one of the following constants::
|
||||
|
||||
CONTROLLER_AXIS_LEFTX, CONTROLLER_AXIS_LEFTY,
|
||||
CONTROLLER_AXIS_RIGHTX, CONTROLLER_AXIS_RIGHTY,
|
||||
CONTROLLER_AXIS_TRIGGERLEFT, CONTROLLER_AXIS_TRIGGERRIGHT
|
||||
|
||||
Joysticks can return a value between -32768 and 32767. Triggers however
|
||||
can only return a value between 0 and 32768.
|
||||
|
||||
.. ## Controller.get_axis ##
|
||||
|
||||
.. method:: get_button
|
||||
|
||||
| :sl:`Get the current state of a button`
|
||||
| :sg:`get_button(button) -> bool`
|
||||
|
||||
Get the current state of a button, True meaning it is pressed down.
|
||||
The button argument must be one of the following constants::
|
||||
|
||||
CONTROLLER_BUTTON_A, CONTROLLER_BUTTON_B,
|
||||
CONTROLLER_BUTTON_X, CONTROLLER_BUTTON_Y
|
||||
CONTROLLER_BUTTON_DPAD_UP, CONTROLLER_BUTTON_DPAD_DOWN,
|
||||
CONTROLLER_BUTTON_DPAD_LEFT, CONTROLLER_BUTTON_DPAD_RIGHT,
|
||||
CONTROLLER_BUTTON_LEFTSHOULDER, CONTROLLER_BUTTON_RIGHTSHOULDER,
|
||||
CONTROLLER_BUTTON_LEFTSTICK, CONTROLLER_BUTTON_RIGHTSTICK,
|
||||
CONTROLLER_BUTTON_BACK, CONTROLLER_BUTTON_GUIDE,
|
||||
CONTROLLER_BUTTON_START
|
||||
|
||||
|
||||
.. ## Controller.get_button ##
|
||||
|
||||
.. method:: get_mapping
|
||||
|
||||
| :sl:`Get the mapping assigned to the controller`
|
||||
| :sg:`get_mapping() -> mapping`
|
||||
|
||||
Returns a dict containing the mapping of the Controller. For more
|
||||
information see :meth:`Controller.set_mapping()`
|
||||
|
||||
.. versionchangedold:: 2.0.2: Return type changed from ``str`` to ``dict``
|
||||
|
||||
.. ## Controller.get_mapping ##
|
||||
|
||||
.. method:: set_mapping
|
||||
|
||||
| :sl:`Assign a mapping to the controller`
|
||||
| :sg:`set_mapping(mapping) -> int`
|
||||
|
||||
Rebind buttons, axes, triggers and dpads. The mapping should be a
|
||||
dict containing all buttons, hats and axes. The easiest way to get this
|
||||
is to use the dict returned by :meth:`Controller.get_mapping`. To edit
|
||||
this mapping assign a value to the original button. The value of the
|
||||
dictionary must be a button, hat or axis represented in the following way:
|
||||
|
||||
* For a button use: bX where X is the index of the button.
|
||||
* For a hat use: hX.Y where X is the index and the Y is the direction (up: 1, right: 2, down: 3, left: 4).
|
||||
* For an axis use: aX where x is the index of the axis.
|
||||
|
||||
An example of mapping::
|
||||
|
||||
mapping = controller.get_mapping() # Get current mapping
|
||||
mapping["a"] = "b3" # Remap button a to y
|
||||
mapping["y"] = "b0" # Remap button y to a
|
||||
controller.set_mapping(mapping) # Set the mapping
|
||||
|
||||
|
||||
The function will return 1 if a new mapping is added or 0 if an existing one is updated.
|
||||
|
||||
.. versionchangedold:: 2.0.2: Renamed from ``add_mapping`` to ``set_mapping``
|
||||
.. versionchangedold:: 2.0.2: Argument type changed from ``str`` to ``dict``
|
||||
|
||||
.. ## Controller.set_mapping ##
|
||||
|
||||
.. method:: rumble
|
||||
|
||||
| :sl:`Start a rumbling effect`
|
||||
| :sg:`rumble(low_frequency, high_frequency, duration) -> bool`
|
||||
|
||||
Start a rumble effect on the controller, with the specified strength ranging
|
||||
from 0 to 1. Duration is length of the effect, in ms. Setting the duration
|
||||
to 0 will play the effect until another one overwrites it or
|
||||
:meth:`Controller.stop_rumble` is called. If an effect is already
|
||||
playing, then it will be overwritten.
|
||||
|
||||
Returns True if the rumble was played successfully or False if the
|
||||
controller does not support it.
|
||||
|
||||
.. versionaddedold:: 2.0.2
|
||||
|
||||
.. ## Controller.rumble ##
|
||||
|
||||
.. method:: stop_rumble
|
||||
|
||||
| :sl:`Stop any rumble effect playing`
|
||||
| :sg:`stop_rumble() -> None`
|
||||
|
||||
Stops any rumble effect playing on the controller. See
|
||||
:meth:`Controller.rumble` for more information.
|
||||
|
||||
.. versionaddedold:: 2.0.2
|
||||
|
||||
.. ## Controller.stop_rumble ##
|
||||
|
||||
.. method:: set_led
|
||||
|
||||
| :sl:`Set the LED color of the controller`
|
||||
| :sg:`set_led(color_arg) -> bool`
|
||||
|
||||
Set the color of the LED on the controller. The argument is a
|
||||
``pygame.Color``-compatible value (alpha being ignored). The
|
||||
controller's LED, if it has one, will be set to the input color.
|
||||
If the controller does not have an addressable LED, then this
|
||||
method will do nothing and return False. Returns True if the
|
||||
LED was set successfully.
|
||||
|
||||
.. versionadded:: 2.5.6
|
||||
|
||||
.. ## Controller.set_led ##
|
||||
|
||||
.. ## pygame._sdl2.controller ##
|
||||
@@ -0,0 +1,549 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.sdl2_video`
|
||||
========================
|
||||
|
||||
.. module:: pygame._sdl2.video
|
||||
:synopsis: Experimental pygame module for porting new SDL video systems
|
||||
|
||||
.. warning::
|
||||
This module isn't ready for prime time yet, it's still in development.
|
||||
These docs are primarily meant to help the pygame developers and
|
||||
super-early adopters who are in communication with the developers.
|
||||
This API will change.
|
||||
|
||||
| :sl:`Experimental pygame module for porting new SDL video systems`
|
||||
|
||||
.. class:: RendererDriverInfo
|
||||
|
||||
| :sl:`pygame object encapsulating Renderer driver information`
|
||||
|
||||
Attributes:
|
||||
|
||||
::
|
||||
|
||||
name
|
||||
flags
|
||||
num_texture_formats
|
||||
max_texture_width
|
||||
max_texture_height
|
||||
|
||||
.. function:: get_drivers
|
||||
|
||||
| :sl:`Yield info about the rendering drivers available for Renderer objects`
|
||||
| :sg:`get_drivers() -> Iterator[RendererDriverInfo]`
|
||||
|
||||
.. function:: get_grabbed_window
|
||||
|
||||
| :sl:`Get the window with input grab enabled`
|
||||
| :sg:`get_grabbed_window() -> Window or None`
|
||||
|
||||
Gets the :class:`Window` with input grab enabled, if input is grabbed,
|
||||
otherwise ``None`` is returned.
|
||||
|
||||
|
||||
.. class:: Window
|
||||
|
||||
| :sl:`pygame object that represents a window`
|
||||
|
||||
See :class:`pygame.Window`
|
||||
|
||||
.. class:: Texture
|
||||
|
||||
| :sl:`pygame object that represents a texture`
|
||||
| :sg:`Texture(renderer, size, depth=0, static=False, streaming=False, target=False, scale_quality=None) -> Texture`
|
||||
|
||||
Creates an empty texture.
|
||||
|
||||
:param Renderer renderer: The rendering context for the texture.
|
||||
:param tuple size: The width and height for the texture.
|
||||
:param int depth: The pixel format (``0`` to use the default).
|
||||
:param bool static: Initialize the texture as static
|
||||
(changes rarely, not lockable).
|
||||
:param bool streaming: Initialize the texture as streaming
|
||||
(changes frequently, lockable).
|
||||
:param bool target: Initialize the texture as target
|
||||
(can be used as a rendering target).
|
||||
:param int scale_quality: Set the texture scale quality. Can be ``0``
|
||||
(nearest pixel sampling), ``1``
|
||||
(linear filtering, supported by OpenGL and Direct3D)
|
||||
and ``2`` (anisotropic filtering, supported by Direct3D).
|
||||
|
||||
One of ``static``, ``streaming``, or ``target`` can be set
|
||||
to ``True``. If all are ``False``, then ``static`` is used.
|
||||
|
||||
|
||||
:class:`Texture` objects provide a platform-agnostic API for working with GPU textures.
|
||||
They are stored in GPU video memory (VRAM), and are therefore very fast to
|
||||
rotate and resize when drawn onto a :class:`Renderer`
|
||||
(an object that manages a rendering context inside a :class:`Window`) on most GPUs.
|
||||
|
||||
Since textures are stored in GPU video memory, they aren't as easy to modify
|
||||
as the image data of :class:`pygame.Surface` objects, which reside in RAM.
|
||||
|
||||
Textures can be modified in 2 ways:
|
||||
|
||||
* By drawing other textures onto them, achieved by marking them as "target" textures and setting them as the rendering target of their Renderer object (if properly configured and supported).
|
||||
|
||||
* By updating them with a Surface.
|
||||
|
||||
.. note::
|
||||
A :class:`pygame.Surface`-to-:class:`Texture` update is generally
|
||||
considered a slow operation, as it requires image data to be uploaded from
|
||||
RAM to VRAM, which can have a notable overhead cost.
|
||||
|
||||
.. attribute:: renderer
|
||||
|
||||
| :sl:`Get the renderer associated with the texture (**read-only**)`
|
||||
| :sg:`renderer -> Renderer`
|
||||
|
||||
.. attribute:: width
|
||||
|
||||
| :sl:`Get the width of the texture (**read-only**)`
|
||||
| :sg:`width -> int`
|
||||
|
||||
.. attribute:: height
|
||||
|
||||
| :sl:`Get the height of the texture (**read-only**)`
|
||||
| :sg:`height -> int`
|
||||
|
||||
.. attribute:: alpha
|
||||
|
||||
| :sl:`Get or set the additional alpha value multiplied into draw operations`
|
||||
| :sg:`alpha -> int`
|
||||
|
||||
.. attribute:: blend_mode
|
||||
|
||||
| :sl:`Get or set the blend mode for texture drawing operations`
|
||||
| :sg:`blend_mode -> int`
|
||||
|
||||
Gets or sets the blend mode for the texture's drawing operations.
|
||||
Valid blend modes are any of the ``BLENDMODE_*`` constants or a custom one.
|
||||
|
||||
.. attribute:: color
|
||||
|
||||
| :sl:`Get or set the additional color value multiplied into texture drawing operations`
|
||||
| :sg:`color -> Color`
|
||||
|
||||
.. staticmethod:: from_surface
|
||||
|
||||
| :sl:`Create a texture from an existing surface`
|
||||
| :sg:`from_surface(renderer, surface) -> Texture`
|
||||
|
||||
:param Renderer renderer: Rendering context for the texture.
|
||||
:param Surface surface: The surface to create a texture from.
|
||||
|
||||
.. method:: get_rect
|
||||
|
||||
| :sl:`Get the rectangular area of the texture`
|
||||
| :sg:`get_rect(**kwargs) -> Rect`
|
||||
|
||||
Like :meth:`pygame.Surface.get_rect`, this method returns a **new**
|
||||
:class:`pygame.Rect` covering the entire texture. It will always
|
||||
have a ``topleft`` of ``(0, 0)`` with a ``width`` and ``height`` the same size as the
|
||||
texture.
|
||||
|
||||
.. method:: draw
|
||||
|
||||
| :sl:`Copy a portion of the texture to the rendering target`
|
||||
| :sg:`draw(srcrect=None, dstrect=None, angle=0, origin=None, flip_x=False, flip_y=False) -> None`
|
||||
|
||||
:param srcrect: The source rectangle on the texture, or ``None`` for the
|
||||
entire texture.
|
||||
:param dstrect: The destination rectangle on the rendering target, or
|
||||
``None`` for the entire rendering target. The texture
|
||||
will be stretched to fill ``dstrect``.
|
||||
:param float angle: The angle (in degrees) to rotate dstrect around
|
||||
(clockwise).
|
||||
:param origin: The point around which dstrect will be rotated.
|
||||
If ``None``, it will equal the center:
|
||||
``(dstrect.w/2, dstrect.h/2)``.
|
||||
:param bool flip_x: Flip the drawn texture portion horizontally (x - axis).
|
||||
:param bool flip_y: Flip the drawn texture portion vertically (y - axis).
|
||||
|
||||
.. method:: draw_triangle
|
||||
|
||||
| :sl:`Copy a triangle portion of the texture to the rendering target using the given coordinates`
|
||||
| :sg:`draw_triangle(p1_xy, p2_xy, p3_xy, p1_uv=(0.0, 0.0), p2_uv=(1.0, 1.0), p3_uv=(0.0, 1.0), p1_mod=(255, 255, 255, 255), p2_mod=(255, 255, 255, 255), p3_mod=(255, 255, 255, 255)) -> None`
|
||||
|
||||
:param p1_xy: The first vertex coordinate on the rendering target.
|
||||
:param p2_xy: The second vertex coordinate on the rendering target.
|
||||
:param p3_xy: The third vertex coordinate on the rendering target.
|
||||
:param p1_uv: The first UV coordinate of the triangle portion.
|
||||
:param p2_uv: The second UV coordinate of the triangle portion.
|
||||
:param p3_uv: The third UV coordinate of the triangle portion.
|
||||
:param p1_mod: The first vertex color modulation.
|
||||
:param p2_mod: The second vertex color modulation.
|
||||
:param p3_mod: The third vertex color modulation.
|
||||
|
||||
.. method:: draw_quad
|
||||
|
||||
| :sl:`Copy a quad portion of the texture to the rendering target using the given coordinates`
|
||||
| :sg:`draw_quad(p1_xy, p2_xy, p3_xy, p4_xy, p1_uv=(0.0, 0.0), p2_uv=(1.0, 0.0), p3_uv=(1.0, 1.0), p4_uv=(0.0, 1.0), p1_mod=(255, 255, 255, 255), p2_mod=(255, 255, 255, 255), p3_mod=(255, 255, 255, 255), p4_mod=(255, 255, 255, 255)) -> None`
|
||||
|
||||
:param p1_xy: The first vertex coordinate on the rendering target.
|
||||
:param p2_xy: The second vertex coordinate on the rendering target.
|
||||
:param p3_xy: The third vertex coordinate on the rendering target.
|
||||
:param p4_xy: The fourth vertex coordinate on the rendering target.
|
||||
:param p1_uv: The first UV coordinate of the quad portion.
|
||||
:param p2_uv: The second UV coordinate of the quad portion.
|
||||
:param p3_uv: The third UV coordinate of the quad portion.
|
||||
:param p4_uv: The fourth UV coordinate of the quad portion.
|
||||
:param p1_mod: The first vertex color modulation.
|
||||
:param p2_mod: The second vertex color modulation.
|
||||
:param p3_mod: The third vertex color modulation.
|
||||
:param p4_mod: The fourth vertex color modulation.
|
||||
|
||||
.. method:: update
|
||||
|
||||
| :sl:`Update the texture with Surface (slow operation, use sparingly)`
|
||||
| :sg:`update(surface, area=None) -> None`
|
||||
|
||||
:param Surface surface: The source surface.
|
||||
:param area: The rectangular area of the texture to update.
|
||||
|
||||
.. note::
|
||||
This is a fairly slow function, intended for use with static textures
|
||||
that do not change often.
|
||||
|
||||
If the texture is intended to be updated often, it is preferred to create
|
||||
the texture as streaming and use the locking functions.
|
||||
|
||||
While this function will work with streaming textures, for optimization
|
||||
reasons you may not get the pixels back if you lock the texture afterward.
|
||||
|
||||
|
||||
.. class:: Image
|
||||
|
||||
| :sl:`pygame object that represents a portion of a texture`
|
||||
| :sg:`Image(texture_or_image, srcrect=None) -> Image`
|
||||
|
||||
Creates an Image.
|
||||
|
||||
:param Texture | Image texture_or_image: The Texture or an existing Image
|
||||
object to create the Image from.
|
||||
:param srcrect: The rectangular portion of the Texture or Image object
|
||||
passed to ``texture_or_image``.
|
||||
|
||||
An :class:`Image` object represents a portion of a :class:`Texture`. Specifically,
|
||||
they can be used to store and manipulate arguments for :meth:`Texture.draw`
|
||||
in a more user-friendly way.
|
||||
|
||||
.. attribute:: angle
|
||||
|
||||
| :sl:`Get and set the angle the Image draws itself with`
|
||||
| :sg:`angle -> float`
|
||||
|
||||
.. attribute:: flip_x
|
||||
|
||||
| :sl:`Get or set whether the Image is flipped on the x axis`
|
||||
| :sg:`flip_x -> bool`
|
||||
|
||||
.. attribute:: flip_y
|
||||
|
||||
| :sl:`Get or set whether the Image is flipped on the y axis`
|
||||
| :sg:`flip_y -> bool`
|
||||
|
||||
.. attribute:: color
|
||||
|
||||
| :sl:`Get or set the Image color modifier`
|
||||
| :sg:`color -> Color`
|
||||
|
||||
.. attribute:: alpha
|
||||
|
||||
| :sl:`Get or set the Image alpha modifier (0-255)`
|
||||
| :sg:`alpha -> float`
|
||||
|
||||
.. attribute:: blend_mode
|
||||
|
||||
| :sl:`Get or set the blend mode for the Image`
|
||||
| :sg:`blend_mode -> int`
|
||||
|
||||
.. attribute:: texture
|
||||
|
||||
| :sl:`Get or set the Texture the Image is based on`
|
||||
| :sg:`texture -> Texture`
|
||||
|
||||
.. attribute:: srcrect
|
||||
|
||||
| :sl:`Get or set the Rect the Image is based on`
|
||||
| :sg:`srcrect -> Rect`
|
||||
|
||||
.. attribute:: origin
|
||||
|
||||
| :sl:`Get or set the Image's origin of rotation`
|
||||
| :sg:`origin -> (float, float) or None`
|
||||
|
||||
Gets or sets the Image's origin of rotation, a 2D point relative to
|
||||
the topleft coordinates of the Image's rectangular area.
|
||||
|
||||
An origin of ``None`` means no origin was set and the Image will be
|
||||
rotated around its center.
|
||||
|
||||
.. method:: get_rect
|
||||
|
||||
| :sl:`Get the rectangular area of the Image`
|
||||
| :sg:`get_rect() -> Rect`
|
||||
|
||||
.. note::
|
||||
The returned :class:`Rect` object might contain position information
|
||||
relative to the bounds of the :class:`Texture` or Image object it was
|
||||
created from.
|
||||
|
||||
.. method:: draw
|
||||
|
||||
| :sl:`Copy a portion of the Image to the rendering target`
|
||||
| :sg:`draw(srcrect=None, dstrect=None) -> None`
|
||||
|
||||
:param srcrect: Source rectangle specifying a sub-Image, or ``None`` for the
|
||||
entire Image.
|
||||
:param dstrect: Destination rectangle or position on the render target,
|
||||
or ``None`` for entire target. The Image is stretched to
|
||||
fill dstrect.
|
||||
|
||||
|
||||
.. class:: Renderer
|
||||
|
||||
| :sl:`pygame object wrapping a 2D rendering context for a window`
|
||||
| :sg:`Renderer(window, index=-1, accelerated=-1, vsync=False, target_texture=False) -> Renderer`
|
||||
|
||||
Creates a 2D rendering context for a window.
|
||||
|
||||
:param Window window: The window onto which the rendering context should be
|
||||
placed.
|
||||
:param int index: The index of rendering driver to initialize, or ``-1`` to init
|
||||
the first supporting the requested options.
|
||||
:param int accelerated: If 1, the renderer uses hardware acceleration.
|
||||
if 0, the renderer is a software fallback.
|
||||
``-1`` gives precedence to renderers using hardware
|
||||
acceleration.
|
||||
:param bool vsync: If ``True`` :meth:`Renderer.present` is synchronized with
|
||||
the refresh rate.
|
||||
:param bool target_texture: Whether the renderer should support setting
|
||||
:class:`Texture` objects as target textures, to
|
||||
enable drawing onto them.
|
||||
|
||||
|
||||
:class:`Renderer` objects provide a cross-platform API for rendering 2D
|
||||
graphics onto a :class:`Window`, by using either Metal (macOS), OpenGL
|
||||
(macOS, Windows, Linux) or Direct3D (Windows) rendering drivers, depending
|
||||
on what is set or is available on a system during their creation.
|
||||
|
||||
They can be used to draw both :class:`Texture` objects and simple points,
|
||||
lines and rectangles (which are colored based on :attr:`Renderer.draw_color`).
|
||||
|
||||
If configured correctly and supported by an underlying rendering driver, Renderer
|
||||
objects can have a :class:`Texture` object temporarily set as a target texture
|
||||
(the Texture object must have been created with target texture usage support),
|
||||
which allows those textures to be drawn onto.
|
||||
|
||||
To present drawn content onto the window, :meth:`Renderer.present` should be
|
||||
called. :meth:`Renderer.clear` should be called to clear any drawn content
|
||||
with the set Renderer draw color.
|
||||
|
||||
When things are drawn onto Renderer objects, an internal batching system is
|
||||
used by default to batch those "draw calls" together, to have all of them be
|
||||
processed in one go when :meth:`Renderer.present` is called. This is unlike
|
||||
:class:`pygame.Surface` objects, on which modifications via blitting occur
|
||||
immediately, but lends well to the behavior of GPUs, as draw calls can be
|
||||
expensive on lower-end models.
|
||||
|
||||
.. attribute:: draw_blend_mode
|
||||
|
||||
| :sl:`Get or set the blend mode used for primitive drawing operations`
|
||||
| :sg:`draw_blend_mode -> int`
|
||||
|
||||
.. attribute:: draw_color
|
||||
|
||||
| :sl:`Get or set the color used for primitive drawing operations`
|
||||
| :sg:`draw_color -> Color`
|
||||
|
||||
.. attribute:: logical_size
|
||||
|
||||
| :sl:`Get or set the logical Renderer size (a device independent resolution for rendering)`
|
||||
| :sg:`logical_size -> (int width, int height)`
|
||||
|
||||
Note: When the rendering target is the main window, and ``logical_size``
|
||||
has not been set before, it will contain ``(0, 0)`` and not the size of
|
||||
the window.
|
||||
|
||||
.. attribute:: scale
|
||||
|
||||
| :sl:`Get the drawing scale for the current rendering target`
|
||||
| :sg:`scale -> (float, float)`
|
||||
|
||||
.. attribute:: target
|
||||
|
||||
| :sl:`Get or set the current rendering target`
|
||||
| :sg:`target -> Texture or None`
|
||||
|
||||
Gets or sets the current rendering target.
|
||||
A value of ``None`` means that no custom rendering target was set and the
|
||||
Renderer's window will be used as the target.
|
||||
|
||||
.. classmethod:: from_window
|
||||
|
||||
| :sl:`Create a Renderer from an existing window`
|
||||
| :sg:`from_window(window) -> Renderer`
|
||||
|
||||
.. method:: clear
|
||||
|
||||
| :sl:`Clear the current rendering target with the drawing color`
|
||||
| :sg:`clear() -> None`
|
||||
|
||||
.. method:: present
|
||||
|
||||
| :sl:`Update the screen with any rendering performed since the previous call`
|
||||
| :sg:`present() -> None`
|
||||
|
||||
Presents the composed backbuffer to the screen.
|
||||
Updates the screen with any rendering performed since the previous call.
|
||||
|
||||
.. method:: get_viewport
|
||||
|
||||
| :sl:`Get the drawing area on the rendering target`
|
||||
| :sg:`get_viewport() -> Rect`
|
||||
|
||||
.. method:: set_viewport
|
||||
|
||||
| :sl:`Set the drawing area on the rendering target`
|
||||
| :sg:`set_viewport(area) -> None`
|
||||
|
||||
:param area: A :class:`pygame.Rect` or tuple representing the
|
||||
drawing area on the target, or ``None`` to use the
|
||||
entire area of the current rendering target.
|
||||
|
||||
.. method:: coordinates_to_window
|
||||
|
||||
| :sl:`Translates renderer coordinates to window coordinates`
|
||||
| :sg:`coordinates_to_window(point) -> (float, float)`
|
||||
|
||||
:param point: The coordinates in render space.
|
||||
|
||||
.. versionadded:: 2.5.6
|
||||
|
||||
|
||||
.. method:: coordinates_from_window
|
||||
|
||||
| :sl:`Translates window coordinates to renderer coordinates`
|
||||
| :sg:`coordinates_from_window(point) -> (float, float)`
|
||||
|
||||
:param point: The coordinates in window space.
|
||||
|
||||
.. versionadded:: 2.5.6
|
||||
|
||||
.. method:: blit
|
||||
|
||||
| :sl:`Draw textures using a Surface-like API`
|
||||
| :sg:`blit(source, dest, area=None, special_flags=0)-> Rect`
|
||||
|
||||
For compatibility purposes. Draws :class:`Texture` objects onto the
|
||||
Renderer using a method signature similar to :meth:`pygame.Surface.blit`.
|
||||
|
||||
:param source: A :class:`Texture` or :class:`Image` to draw.
|
||||
:param dest: The drawing destination on the rendering target.
|
||||
:param area: The portion of the source texture or image to draw from.
|
||||
:param special_flags: have no effect at this moment.
|
||||
|
||||
.. note:: Textures created by different Renderers cannot shared with each other!
|
||||
|
||||
.. method:: draw_line
|
||||
|
||||
| :sl:`Draw a line`
|
||||
| :sg:`draw_line(p1, p2) -> None`
|
||||
|
||||
:param p1: The line start point.
|
||||
:param p2: The line end point.
|
||||
|
||||
.. method:: draw_point
|
||||
|
||||
| :sl:`Draw a point`
|
||||
| :sg:`draw_point(point) -> None`
|
||||
|
||||
:param point: The point's coordinates.
|
||||
|
||||
.. method:: draw_rect
|
||||
|
||||
| :sl:`Draw a rectangle outline`
|
||||
| :sg:`draw_rect(rect)-> None`
|
||||
|
||||
:param rect: The :class:`pygame.Rect`-like rectangle to draw.
|
||||
|
||||
.. method:: fill_rect
|
||||
|
||||
| :sl:`Draw a filled rectangle`
|
||||
| :sg:`fill_rect(rect)-> None`
|
||||
|
||||
:param rect: The :class:`pygame.Rect`-like rectangle to draw.
|
||||
|
||||
.. method:: draw_triangle
|
||||
|
||||
| :sl:`Draw a triangle outline`
|
||||
| :sg:`draw_triangle(p1, p2, p3) -> None`
|
||||
|
||||
:param p1: The first triangle point.
|
||||
:param p2: The second triangle point.
|
||||
:param p2: The third triangle point.
|
||||
|
||||
.. method:: fill_triangle
|
||||
|
||||
| :sl:`Draw a filled triangle`
|
||||
| :sg:`fill_triangle(p1, p2, p3) -> None`
|
||||
|
||||
:param p1: The first triangle point.
|
||||
:param p2: The second triangle point.
|
||||
:param p2: The third triangle point.
|
||||
|
||||
.. method:: draw_quad
|
||||
|
||||
| :sl:`Draw a quad outline`
|
||||
| :sg:`draw_quad(p1, p2, p3, p4) -> None`
|
||||
|
||||
:param p1: The first quad point.
|
||||
:param p2: The second quad point.
|
||||
:param p2: The third quad point.
|
||||
:param p2: The fourth quad point.
|
||||
|
||||
.. method:: fill_quad
|
||||
|
||||
| :sl:`Draw a filled quad`
|
||||
| :sg:`fill_quad(p1, p2, p3, p4) -> None`
|
||||
|
||||
:param p1: The first quad point.
|
||||
:param p2: The second quad point.
|
||||
:param p2: The third quad point.
|
||||
:param p2: The fourth quad point.
|
||||
|
||||
.. method:: to_surface
|
||||
|
||||
| :sl:`Read pixels from current rendering target and create a Surface (slow operation, use sparingly)`
|
||||
| :sg:`to_surface(surface=None, area=None)-> Surface`
|
||||
|
||||
Read pixel data from the current rendering target and return a
|
||||
:class:`pygame.Surface` containing it.
|
||||
|
||||
:param Surface surface: A :class:`pygame.Surface` object to read the pixel
|
||||
data into. It must be large enough to fit the area, otherwise
|
||||
``ValueError`` is raised.
|
||||
If set to ``None``, a new surface will be created.
|
||||
:param area: The area of the screen to read pixels from. The area is
|
||||
clipped to fit inside the viewport.
|
||||
If ``None``, the entire viewport is used.
|
||||
|
||||
.. note::
|
||||
This is a very slow operation, due to the overhead of the VRAM to RAM
|
||||
data transfer and the cost of creating a potentially large
|
||||
:class:`pygame.Surface`. It should not be used frequently.
|
||||
|
||||
.. method:: compose_custom_blend_mode
|
||||
|
||||
| :sl:`Compose a custom blend mode`
|
||||
| :sg:`compose_custom_blend_mode(color_mode, alpha_mode) -> int`
|
||||
|
||||
Compose a custom blend mode.
|
||||
See https://wiki.libsdl.org/SDL2/SDL_ComposeCustomBlendMode for more information.
|
||||
|
||||
:param color_mode: A tuple ``(srcColorFactor, dstColorFactor, colorOperation)``
|
||||
:param alpha_mode: A tuple ``(srcAlphaFactor, dstAlphaFactor, alphaOperation)``
|
||||
|
||||
:return: A blend mode to be used with :meth:`Renderer.set_draw_blend_mode` and :meth:`Texture.set_blend_mode`.
|
||||
@@ -0,0 +1,7 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.sndarray`
|
||||
======================
|
||||
|
||||
.. autopgmodule:: pygame.sndarray
|
||||
:members:
|
||||
@@ -0,0 +1,115 @@
|
||||
.. include:: common.txt
|
||||
|
||||
====================
|
||||
:mod:`special flags`
|
||||
====================
|
||||
|
||||
What Are Special Flags?
|
||||
=======================
|
||||
|
||||
**Special flags are a means of controlling how a** :class:`Surface` **is drawn onto another**.
|
||||
They can be used to create visual effects, such as glowing particles, or to perform surface
|
||||
masking or manipulation.
|
||||
They are used with the following methods:
|
||||
|
||||
- :meth:`pygame.Surface.blit`
|
||||
- :meth:`pygame.Surface.blits`
|
||||
- :meth:`pygame.Surface.fblits`
|
||||
- :meth:`pygame.Surface.fill`
|
||||
|
||||
Specifically they are passed as the ``special_flags`` argument of these methods by using
|
||||
``pygame.BLEND_*`` constants and allow you to choose how the colors of the surfaces are
|
||||
combined or blended together. Different flags can produce widely different results, so
|
||||
it is important to experiment to understand how they work.
|
||||
|
||||
By default, surfaces are drawn without any special flags, meaning they will be drawn based
|
||||
on their bit ``depth`` and ``colorkey``:
|
||||
|
||||
- If the ``Surface`` has a ``colorkey``, the pixels matching the ``colorkey`` will be transparent.
|
||||
|
||||
- If the ``Surface`` has a per-pixel or global alpha value, the alpha value will be used to blend the
|
||||
pixels with the ``Surface`` below.
|
||||
|
||||
- If the ``Surface`` doesn't have a ``colorkey`` or alpha value, the pixels will be opaque, meaning
|
||||
that the ``Surface`` will effectively overwrite the pixels of the ``Surface`` below.
|
||||
|
||||
The default drawing mode has its own flag: ``BLENDMODE_NONE`` (``0``).
|
||||
|
||||
Special Flags List
|
||||
==================
|
||||
|
||||
**Blending without Alpha Channel (RGB)**
|
||||
|
||||
----
|
||||
|
||||
.. versionaddedold:: 1.8 / 1.8.1
|
||||
|
||||
- ``BLEND_ADD`` / ``BLEND_RGB_ADD``
|
||||
Adds the source color channels to the destination color channels, clamped to a maximum of 255.
|
||||
The result color is always a lighter color or the same color.
|
||||
|
||||
- ``BLEND_SUB`` / ``BLEND_RGB_SUB``
|
||||
Subtracts the source color channels from the destination color channels, clamped to a minimum of 0.
|
||||
The result color is always a darker color or the same color.
|
||||
|
||||
- ``BLEND_MULT`` / ``BLEND_RGB_MULT``
|
||||
Multiplies the destination color channels by the source color channels, divided by 256 (or >> 8).
|
||||
The result color is always a darker color or the same color.
|
||||
|
||||
- ``BLEND_MIN`` / ``BLEND_RGB_MIN``
|
||||
Takes the minimum value between the source and destination color channels.
|
||||
|
||||
- ``BLEND_MAX`` / ``BLEND_RGB_MAX``
|
||||
Takes the maximum value of each color channel
|
||||
|
||||
**Blending with Alpha Channel (RGBA)**
|
||||
|
||||
----
|
||||
|
||||
.. versionaddedold:: 1.8.1
|
||||
|
||||
- ``BLEND_RGBA_ADD``
|
||||
Works like ``BLEND_RGB_ADD``, but also adds the alpha channel.
|
||||
|
||||
- ``BLEND_RGBA_SUB``
|
||||
Works like ``BLEND_RGB_SUB``, but also subtracts the alpha channel.
|
||||
|
||||
- ``BLEND_RGBA_MULT``
|
||||
Works like ``BLEND_RGB_MULT``, but also multiplies the alpha channel.
|
||||
|
||||
- ``BLEND_RGBA_MIN``
|
||||
Works like ``BLEND_RGB_MIN``, but also minimizes the alpha channel.
|
||||
|
||||
- ``BLEND_RGBA_MAX``
|
||||
Works like ``BLEND_RGB_MAX``, but also maximizes the alpha channel.
|
||||
|
||||
**Special Alpha Blending (RGBA)**
|
||||
|
||||
----
|
||||
|
||||
.. versionaddedold:: 1.9.2
|
||||
|
||||
- ``BLEND_PREMULTIPLIED``
|
||||
Uses premultiplied alpha blending for slightly faster blits and more
|
||||
accurate blending results when the color channels are already multiplied
|
||||
by the surface alpha channel.
|
||||
You should only use this blend mode if you previously premultiplied the Surface with
|
||||
:meth:`pygame.Surface.premul_alpha()`, or if you know that the Surface was already
|
||||
created or loaded in with premultiplied alpha colors. You can read more about the
|
||||
advantages of `premultiplied alpha blending
|
||||
here <https://en.wikipedia.org/wiki/Alpha_compositing>`_.
|
||||
|
||||
.. versionaddedold:: 2.0.0
|
||||
|
||||
- ``BLEND_ALPHA_SDL2``
|
||||
Uses the SDL2 blitter for alpha blending, which may give slightly different
|
||||
results compared to the default blitter used in Pygame 1. This algorithm uses
|
||||
different approximations for alpha blending and supports Run-Length Encoding
|
||||
(RLE) on alpha-blended surfaces.
|
||||
|
||||
**Other (RGB / RGBA)**
|
||||
|
||||
----
|
||||
|
||||
- ``BLENDMODE_NONE``
|
||||
It's the default drawing mode. It's equivalent to not passing any special flags.
|
||||
@@ -0,0 +1,860 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.sprite`
|
||||
====================
|
||||
|
||||
.. module:: pygame.sprite
|
||||
:synopsis: pygame module with basic game object classes
|
||||
|
||||
| :sl:`pygame module with basic game object classes`
|
||||
|
||||
This module contains several simple classes to be used within games. There is
|
||||
the main Sprite class and several Group classes that contain Sprites. The use
|
||||
of these classes is entirely optional when using pygame. The classes are fairly
|
||||
lightweight and only provide a starting place for the code that is common to
|
||||
most games.
|
||||
|
||||
The Sprite class is intended to be used as a base class for the different types
|
||||
of objects in the game. There is also a base Group class that simply stores
|
||||
sprites. A game could create new types of Group classes that operate on
|
||||
specially customized Sprite instances they contain.
|
||||
|
||||
The basic Group class can draw the Sprites it contains to a Surface. The
|
||||
``Group.draw()`` method requires that each Sprite have a ``Sprite.image``
|
||||
attribute and a ``Sprite.rect``. The ``Group.clear()`` method requires these
|
||||
same attributes, and can be used to erase all the Sprites with background.
|
||||
There are also more advanced Groups: ``pygame.sprite.RenderUpdates()``.
|
||||
|
||||
Lastly, this module contains several collision functions. These help find
|
||||
sprites inside multiple groups that have intersecting bounding rectangles. To
|
||||
find the collisions, the Sprites are required to have a ``Sprite.rect``
|
||||
attribute assigned.
|
||||
|
||||
The groups are designed for high efficiency in removing and adding Sprites to
|
||||
them. They also allow cheap testing to see if a Sprite already exists in a
|
||||
Group. A given Sprite can exist in any number of groups. A game could use some
|
||||
groups to control object rendering, and a completely separate set of groups to
|
||||
control interaction or player movement. Instead of adding type attributes or
|
||||
bools to a derived Sprite class, consider keeping the Sprites inside organized
|
||||
Groups. This will allow for easier lookup later in the game.
|
||||
|
||||
Sprites and Groups manage their relationships with the ``add()`` and
|
||||
``remove()`` methods. These methods can accept a single or multiple targets for
|
||||
membership. The default initializers for these classes also takes a single or
|
||||
list of targets for initial membership. It is safe to repeatedly add and remove
|
||||
the same Sprite from a Group.
|
||||
|
||||
While it is possible to design sprite and group classes that don't derive from
|
||||
the Sprite and AbstractGroup classes below, it is strongly recommended that you
|
||||
extend those when you add a Sprite or Group class.
|
||||
|
||||
Sprites are not thread safe. So lock them yourself if using threads.
|
||||
|
||||
.. class:: Sprite
|
||||
|
||||
| :sl:`Simple base class for visible game objects.`
|
||||
| :sg:`Sprite(*groups) -> Sprite`
|
||||
|
||||
The base class for visible game objects. Derived classes will want to
|
||||
override the ``Sprite.update()`` and assign a ``Sprite.image`` and
|
||||
``Sprite.rect`` attributes. The initializer can accept any number of Group
|
||||
instances to be added to.
|
||||
|
||||
When subclassing the Sprite, be sure to call the base initializer before
|
||||
adding the Sprite to Groups. For example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class Block(pygame.sprite.Sprite):
|
||||
|
||||
# Constructor. Pass in the color of the block,
|
||||
# and its x and y position
|
||||
def __init__(self, color, width, height):
|
||||
# Call the parent class (Sprite) constructor
|
||||
pygame.sprite.Sprite.__init__(self)
|
||||
|
||||
# Create an image of the block, and fill it with a color.
|
||||
# This could also be an image loaded from the disk.
|
||||
self.image = pygame.Surface([width, height])
|
||||
self.image.fill(color)
|
||||
|
||||
# Fetch the rectangle object that has the dimensions of the image
|
||||
# Update the position of this object by setting the values of rect.x and rect.y
|
||||
self.rect = self.image.get_rect()
|
||||
|
||||
.. method:: update
|
||||
|
||||
| :sl:`method to control sprite behavior`
|
||||
| :sg:`update(*args, **kwargs) -> None`
|
||||
|
||||
The default implementation of this method does nothing; it's just a
|
||||
convenient "hook" that you can override. This method is called by
|
||||
``Group.update()`` with whatever arguments you give it.
|
||||
|
||||
There is no need to use this method if not using the convenience method
|
||||
by the same name in the Group class.
|
||||
|
||||
.. ## Sprite.update ##
|
||||
|
||||
.. method:: add
|
||||
|
||||
| :sl:`add the sprite to groups`
|
||||
| :sg:`add(*groups) -> None`
|
||||
|
||||
Any number of Group instances can be passed as arguments. The Sprite will
|
||||
be added to the Groups it is not already a member of.
|
||||
|
||||
.. ## Sprite.add ##
|
||||
|
||||
.. method:: remove
|
||||
|
||||
| :sl:`remove the sprite from groups`
|
||||
| :sg:`remove(*groups) -> None`
|
||||
|
||||
Any number of Group instances can be passed as arguments. The Sprite will
|
||||
be removed from the Groups it is currently a member of.
|
||||
|
||||
.. ## Sprite.remove ##
|
||||
|
||||
.. method:: kill
|
||||
|
||||
| :sl:`remove the Sprite from all Groups`
|
||||
| :sg:`kill() -> None`
|
||||
|
||||
The Sprite is removed from all the Groups that contain it. This won't
|
||||
change anything about the state of the Sprite. It is possible to continue
|
||||
to use the Sprite after this method has been called, including adding it
|
||||
to Groups.
|
||||
|
||||
.. ## Sprite.kill ##
|
||||
|
||||
.. method:: alive
|
||||
|
||||
| :sl:`does the sprite belong to any groups`
|
||||
| :sg:`alive() -> bool`
|
||||
|
||||
Returns True when the Sprite belongs to one or more Groups.
|
||||
|
||||
.. ## Sprite.alive ##
|
||||
|
||||
.. method:: groups
|
||||
|
||||
| :sl:`list of Groups that contain this Sprite`
|
||||
| :sg:`groups() -> group_list`
|
||||
|
||||
Return a list of all the Groups that contain this Sprite.
|
||||
|
||||
.. ## Sprite.groups ##
|
||||
|
||||
.. ## pygame.sprite.Sprite ##
|
||||
|
||||
.. class:: DirtySprite
|
||||
|
||||
| :sl:`A subclass of Sprite with more attributes and features.`
|
||||
| :sg:`DirtySprite(*groups) -> DirtySprite`
|
||||
|
||||
Extra DirtySprite attributes with their default values:
|
||||
|
||||
dirty = 1
|
||||
|
||||
::
|
||||
|
||||
if set to 1, it is repainted and then set to 0 again
|
||||
if set to 2 then it is always dirty ( repainted each frame,
|
||||
flag is not reset)
|
||||
0 means that it is not dirty and therefore not repainted again
|
||||
|
||||
blendmode = 0
|
||||
|
||||
::
|
||||
|
||||
its the special_flags argument of blit, blendmodes
|
||||
|
||||
source_rect = None
|
||||
|
||||
::
|
||||
|
||||
source rect to use, remember that it is relative to
|
||||
topleft (0,0) of self.image
|
||||
|
||||
visible = 1
|
||||
|
||||
::
|
||||
|
||||
normally 1, if set to 0 it will not be repainted
|
||||
(you must set it dirty too to be erased from screen)
|
||||
|
||||
layer = 0
|
||||
|
||||
::
|
||||
|
||||
(READONLY value, it is read when adding it to the
|
||||
LayeredDirty, for details see doc of LayeredDirty)
|
||||
|
||||
.. ## ##
|
||||
|
||||
.. ## pygame.sprite.DirtySprite ##
|
||||
|
||||
.. class:: Group
|
||||
|
||||
| :sl:`A container class to hold and manage multiple Sprite objects.`
|
||||
| :sg:`Group(*sprites) -> Group`
|
||||
|
||||
A simple container for Sprite objects. This class can be inherited to create
|
||||
containers with more specific behaviors. The constructor takes any number of
|
||||
Sprite arguments to add to the Group. All sprites in groups are stored in the
|
||||
order they were added to the group. The group supports the following
|
||||
standard Python operations:
|
||||
|
||||
::
|
||||
|
||||
in test if a Sprite is contained
|
||||
len the number of Sprites contained
|
||||
bool test if any Sprites are contained
|
||||
iter iterate through all the Sprites
|
||||
|
||||
.. method:: sprites
|
||||
|
||||
| :sl:`list of the Sprites this Group contains`
|
||||
| :sg:`sprites() -> sprite_list`
|
||||
|
||||
Return a list of all the Sprites this group contains. You can also get an
|
||||
iterator from the group, but you cannot iterate over a Group while
|
||||
modifying it.
|
||||
|
||||
.. ## Group.sprites ##
|
||||
|
||||
.. method:: copy
|
||||
|
||||
| :sl:`duplicate the Group`
|
||||
| :sg:`copy() -> Group`
|
||||
|
||||
Creates a new Group with all the same Sprites as the original. If you
|
||||
have subclassed Group, the new object will have the same (sub-)class as
|
||||
the original. This only works if the derived class's constructor takes
|
||||
the same arguments as the Group class's.
|
||||
|
||||
.. ## Group.copy ##
|
||||
|
||||
.. method:: add
|
||||
|
||||
| :sl:`add Sprites to this Group`
|
||||
| :sg:`add(*sprites) -> None`
|
||||
|
||||
Add any number of Sprites to this Group. This will only add Sprites that
|
||||
are not already members of the Group.
|
||||
|
||||
Each sprite argument can also be an iterator containing Sprites.
|
||||
|
||||
.. ## Group.add ##
|
||||
|
||||
.. method:: remove
|
||||
|
||||
| :sl:`remove Sprites from the Group`
|
||||
| :sg:`remove(*sprites) -> None`
|
||||
|
||||
Remove any number of Sprites from the Group. This will only remove
|
||||
Sprites that are already members of the Group.
|
||||
|
||||
Each sprite argument can also be an iterator containing Sprites.
|
||||
|
||||
.. ## Group.remove ##
|
||||
|
||||
.. method:: has
|
||||
|
||||
| :sl:`test if a Group contains Sprites`
|
||||
| :sg:`has(*sprites) -> bool`
|
||||
|
||||
Return True if the Group contains all of the given sprites. This is
|
||||
similar to using the "in" operator on the Group ("if sprite in group:
|
||||
..."), which tests if a single Sprite belongs to a Group.
|
||||
|
||||
Each sprite argument can also be an iterator containing Sprites.
|
||||
|
||||
.. ## Group.has ##
|
||||
|
||||
.. method:: update
|
||||
|
||||
| :sl:`call the update method on contained Sprites`
|
||||
| :sg:`update(*args, **kwargs) -> None`
|
||||
|
||||
Calls the ``update()`` method on all Sprites in the Group. The base
|
||||
Sprite class has an update method that takes any number of arguments and
|
||||
does nothing. The arguments passed to ``Group.update()`` will be passed
|
||||
to each Sprite.
|
||||
|
||||
There is no way to get the return value from the ``Sprite.update()``
|
||||
methods.
|
||||
|
||||
.. ## Group.update ##
|
||||
|
||||
.. method:: draw
|
||||
|
||||
| :sl:`blit the Sprite images`
|
||||
| :sg:`draw(Surface, bgd=None, special_flags=0) -> list[Rect]`
|
||||
|
||||
Draws the contained Sprites to the Surface argument. This uses the
|
||||
``Sprite.image`` attribute for the source surface, and ``Sprite.rect``
|
||||
for the position. ``special_flags`` is passed to ``Surface.blit()``.
|
||||
``bgd`` is unused in this method but ``LayeredDirty.draw()`` uses
|
||||
it.
|
||||
|
||||
The Group keeps sprites in the order they were added, they will be drawn in this order.
|
||||
|
||||
.. versionchanged:: 2.5.4 Added the ``bgd`` and ``special_flags`` arguments
|
||||
|
||||
.. ## Group.draw ##
|
||||
|
||||
.. method:: clear
|
||||
|
||||
| :sl:`draw a background over the Sprites`
|
||||
| :sg:`clear(Surface_dest, background) -> None`
|
||||
|
||||
Erases the Sprites used in the last ``Group.draw()`` call. The
|
||||
destination Surface is cleared by filling the drawn Sprite positions with
|
||||
the background.
|
||||
|
||||
The background is usually a Surface image the same dimensions as the
|
||||
destination Surface. However, it can also be a callback function that
|
||||
takes two arguments; the destination Surface and an area to clear. The
|
||||
background callback function will be called several times each clear.
|
||||
|
||||
Here is an example callback that will clear the Sprites with solid red:
|
||||
|
||||
::
|
||||
|
||||
def clear_callback(surf, rect):
|
||||
color = 255, 0, 0
|
||||
surf.fill(color, rect)
|
||||
|
||||
.. ## Group.clear ##
|
||||
|
||||
.. method:: empty
|
||||
|
||||
| :sl:`remove all Sprites`
|
||||
| :sg:`empty() -> None`
|
||||
|
||||
Removes all Sprites from this Group.
|
||||
|
||||
.. ## Group.empty ##
|
||||
|
||||
.. ## pygame.sprite.Group ##
|
||||
|
||||
.. class:: RenderUpdates
|
||||
|
||||
| :sl:`Group sub-class that tracks dirty updates.`
|
||||
| :sg:`RenderUpdates(*sprites) -> RenderUpdates`
|
||||
|
||||
This class is derived from ``pygame.sprite.Group()``. It has an extended
|
||||
``draw()`` method that tracks the changed areas of the screen.
|
||||
|
||||
.. method:: draw
|
||||
|
||||
| :sl:`blit the Sprite images and track changed areas`
|
||||
| :sg:`draw(surface, bgd=None, special_flags=0) -> Rect_list`
|
||||
|
||||
Draws all the Sprites to the surface, the same as ``Group.draw()``. This
|
||||
method also returns a list of Rectangular areas on the screen that have
|
||||
been changed. The returned changes include areas of the screen that have
|
||||
been affected by previous ``Group.clear()`` calls. ``special_flags`` is
|
||||
passed to ``Surface.blit()``. ``bgd`` is unused in this method but
|
||||
``LayeredDirty.draw()`` uses it.
|
||||
|
||||
The returned Rect list should be passed to ``pygame.display.update()``.
|
||||
This will help performance on software driven display modes. This type of
|
||||
updating is usually only helpful on destinations with non-animating
|
||||
backgrounds.
|
||||
|
||||
.. versionchanged:: 2.5.4 Added the ``bgd`` and ``special_flags`` arguments
|
||||
|
||||
.. ## RenderUpdates.draw ##
|
||||
|
||||
.. ## pygame.sprite.RenderUpdates ##
|
||||
|
||||
.. class:: LayeredUpdates
|
||||
|
||||
| :sl:`LayeredUpdates is a sprite group that handles layers and draws like RenderUpdates.`
|
||||
| :sg:`LayeredUpdates(*sprites, **kwargs) -> LayeredUpdates`
|
||||
|
||||
This group is fully compatible with :class:`pygame.sprite.Sprite`.
|
||||
|
||||
You can set the default layer through kwargs using 'default_layer' and an
|
||||
integer for the layer. The default layer is 0.
|
||||
|
||||
If the sprite you add has an attribute _layer then that layer will be used.
|
||||
If the \**kwarg contains 'layer' then the sprites passed will be added to
|
||||
that layer (overriding the ``sprite.layer`` attribute). If neither sprite
|
||||
has attribute layer nor \**kwarg then the default layer is used to add the
|
||||
sprites.
|
||||
|
||||
.. versionaddedold:: 1.8
|
||||
|
||||
.. method:: add
|
||||
|
||||
| :sl:`add a sprite or sequence of sprites to a group`
|
||||
| :sg:`add(*sprites, **kwargs) -> None`
|
||||
|
||||
If the ``sprite(s)`` have an attribute layer then that is used for the
|
||||
layer. If \**kwargs contains 'layer' then the ``sprite(s)`` will be added
|
||||
to that argument (overriding the sprite layer attribute). If neither is
|
||||
passed then the ``sprite(s)`` will be added to the default layer.
|
||||
|
||||
.. ## LayeredUpdates.add ##
|
||||
|
||||
.. method:: sprites
|
||||
|
||||
| :sl:`returns an ordered list of sprites (first back, last top).`
|
||||
| :sg:`sprites() -> sprites`
|
||||
|
||||
.. ## LayeredUpdates.sprites ##
|
||||
|
||||
.. method:: draw
|
||||
|
||||
| :sl:`draw all sprites in the right order onto the passed surface.`
|
||||
| :sg:`draw(surface, bgd=None, special_flags=0) -> Rect_list`
|
||||
|
||||
.. versionchanged:: 2.5.4 Added the ``bgd`` and ``special_flags`` arguments
|
||||
|
||||
.. ## LayeredUpdates.draw ##
|
||||
|
||||
.. method:: get_sprites_at
|
||||
|
||||
| :sl:`returns a list with all sprites at that position.`
|
||||
| :sg:`get_sprites_at(pos) -> colliding_sprites`
|
||||
|
||||
Bottom sprites first, top last.
|
||||
|
||||
.. ## LayeredUpdates.get_sprites_at ##
|
||||
|
||||
.. method:: get_sprite
|
||||
|
||||
| :sl:`returns the sprite at the index idx from the groups sprites`
|
||||
| :sg:`get_sprite(idx) -> sprite`
|
||||
|
||||
Raises IndexOutOfBounds if the idx is not within range.
|
||||
|
||||
.. ## LayeredUpdates.get_sprite ##
|
||||
|
||||
.. method:: remove_sprites_of_layer
|
||||
|
||||
| :sl:`removes all sprites from a layer and returns them as a list.`
|
||||
| :sg:`remove_sprites_of_layer(layer_nr) -> sprites`
|
||||
|
||||
.. ## LayeredUpdates.remove_sprites_of_layer ##
|
||||
|
||||
.. method:: layers
|
||||
|
||||
| :sl:`returns a list of layers defined (unique), sorted from bottom up.`
|
||||
| :sg:`layers() -> layers`
|
||||
|
||||
.. ## LayeredUpdates.layers ##
|
||||
|
||||
.. method:: change_layer
|
||||
|
||||
| :sl:`changes the layer of the sprite`
|
||||
| :sg:`change_layer(sprite, new_layer) -> None`
|
||||
|
||||
sprite must have been added to the renderer. It is not checked.
|
||||
|
||||
.. ## LayeredUpdates.change_layer ##
|
||||
|
||||
.. method:: get_layer_of_sprite
|
||||
|
||||
| :sl:`returns the layer that sprite is currently in.`
|
||||
| :sg:`get_layer_of_sprite(sprite) -> layer`
|
||||
|
||||
If the sprite is not found then it will return the default layer.
|
||||
|
||||
.. ## LayeredUpdates.get_layer_of_sprite ##
|
||||
|
||||
.. method:: get_top_layer
|
||||
|
||||
| :sl:`returns the top layer`
|
||||
| :sg:`get_top_layer() -> layer`
|
||||
|
||||
.. ## LayeredUpdates.get_top_layer ##
|
||||
|
||||
.. method:: get_bottom_layer
|
||||
|
||||
| :sl:`returns the bottom layer`
|
||||
| :sg:`get_bottom_layer() -> layer`
|
||||
|
||||
.. ## LayeredUpdates.get_bottom_layer ##
|
||||
|
||||
.. method:: move_to_front
|
||||
|
||||
| :sl:`brings the sprite to front layer`
|
||||
| :sg:`move_to_front(sprite) -> None`
|
||||
|
||||
Brings the sprite to front, changing sprite layer to topmost layer (added
|
||||
at the end of that layer).
|
||||
|
||||
.. ## LayeredUpdates.move_to_front ##
|
||||
|
||||
.. method:: move_to_back
|
||||
|
||||
| :sl:`moves the sprite to the bottom layer`
|
||||
| :sg:`move_to_back(sprite) -> None`
|
||||
|
||||
Moves the sprite to the bottom layer, moving it behind all other layers
|
||||
and adding one additional layer.
|
||||
|
||||
.. ## LayeredUpdates.move_to_back ##
|
||||
|
||||
.. method:: get_top_sprite
|
||||
|
||||
| :sl:`returns the topmost sprite`
|
||||
| :sg:`get_top_sprite() -> Sprite`
|
||||
|
||||
.. ## LayeredUpdates.get_top_sprite ##
|
||||
|
||||
.. method:: get_sprites_from_layer
|
||||
|
||||
| :sl:`returns all sprites from a layer, ordered by how they where added`
|
||||
| :sg:`get_sprites_from_layer(layer) -> sprites`
|
||||
|
||||
Returns all sprites from a layer, ordered by how they where added. It
|
||||
uses linear search and the sprites are not removed from layer.
|
||||
|
||||
.. ## LayeredUpdates.get_sprites_from_layer ##
|
||||
|
||||
.. method:: switch_layer
|
||||
|
||||
| :sl:`switches the sprites from layer1 to layer2`
|
||||
| :sg:`switch_layer(layer1_nr, layer2_nr) -> None`
|
||||
|
||||
The layers number must exist, it is not checked.
|
||||
|
||||
.. ## LayeredUpdates.switch_layer ##
|
||||
|
||||
.. ## pygame.sprite.LayeredUpdates ##
|
||||
|
||||
.. class:: LayeredDirty
|
||||
|
||||
| :sl:`LayeredDirty group is for DirtySprite objects. Subclasses LayeredUpdates.`
|
||||
| :sg:`LayeredDirty(*sprites, **kwargs) -> LayeredDirty`
|
||||
|
||||
This group requires :class:`pygame.sprite.DirtySprite` or any sprite that
|
||||
has the following attributes:
|
||||
|
||||
::
|
||||
|
||||
image, rect, dirty, visible, blendmode (see doc of DirtySprite).
|
||||
|
||||
It uses the dirty flag technique and is therefore faster than the
|
||||
:class:`pygame.sprite.RenderUpdates` if you have many static sprites. It
|
||||
also switches automatically between dirty rect update and full screen
|
||||
drawing, so you do not have to worry what would be faster.
|
||||
|
||||
Same as for the :class:`pygame.sprite.Group`. You can specify some
|
||||
additional attributes through kwargs:
|
||||
|
||||
::
|
||||
|
||||
_use_update: True/False default is False
|
||||
_default_layer: default layer where sprites without a layer are added.
|
||||
_time_threshold: threshold time for switching between dirty rect mode
|
||||
and fullscreen mode, defaults to 1000./80 == 1000./fps
|
||||
|
||||
.. versionaddedold:: 1.8
|
||||
|
||||
.. method:: draw
|
||||
|
||||
| :sl:`draw all sprites in the right order onto the passed surface.`
|
||||
| :sg:`draw(surface, bgd=None, special_flags=None) -> Rect_list`
|
||||
|
||||
You can pass the background too. If a background is already set, then the
|
||||
bgd argument has no effect. ``special_flags`` is passed to
|
||||
``Surface.blit()``.
|
||||
|
||||
.. versionchanged:: 2.5.4 Added the ``special_flags`` argument
|
||||
|
||||
.. ## LayeredDirty.draw ##
|
||||
|
||||
.. method:: clear
|
||||
|
||||
| :sl:`used to set background`
|
||||
| :sg:`clear(surface, bgd) -> None`
|
||||
|
||||
.. ## LayeredDirty.clear ##
|
||||
|
||||
.. method:: repaint_rect
|
||||
|
||||
| :sl:`repaints the given area`
|
||||
| :sg:`repaint_rect(screen_rect) -> None`
|
||||
|
||||
screen_rect is in screen coordinates.
|
||||
|
||||
.. ## LayeredDirty.repaint_rect ##
|
||||
|
||||
.. method:: set_clip
|
||||
|
||||
| :sl:`clip the area where to draw. Just pass None (default) to reset the clip`
|
||||
| :sg:`set_clip(screen_rect=None) -> None`
|
||||
|
||||
.. ## LayeredDirty.set_clip ##
|
||||
|
||||
.. method:: get_clip
|
||||
|
||||
| :sl:`clip the area where to draw. Just pass None (default) to reset the clip`
|
||||
| :sg:`get_clip() -> Rect`
|
||||
|
||||
.. ## LayeredDirty.get_clip ##
|
||||
|
||||
.. method:: change_layer
|
||||
|
||||
| :sl:`changes the layer of the sprite`
|
||||
| :sg:`change_layer(sprite, new_layer) -> None`
|
||||
|
||||
sprite must have been added to the renderer. It is not checked.
|
||||
|
||||
.. ## LayeredDirty.change_layer ##
|
||||
|
||||
.. method:: set_timing_treshold
|
||||
|
||||
| :sl:`sets the threshold in milliseconds`
|
||||
| :sg:`set_timing_treshold(time_ms) -> None`
|
||||
|
||||
DEPRECATED: Use set_timing_threshold() instead.
|
||||
|
||||
.. deprecatedold:: 2.1.1
|
||||
|
||||
.. ## LayeredDirty.set_timing_treshold ##
|
||||
|
||||
.. method:: set_timing_threshold
|
||||
|
||||
| :sl:`sets the threshold in milliseconds`
|
||||
| :sg:`set_timing_threshold(time_ms) -> None`
|
||||
|
||||
Defaults to 1000.0 / 80.0. This means that the screen will be painted
|
||||
using the flip method rather than the update method if the update
|
||||
method is taking so long to update the screen that the frame rate falls
|
||||
below 80 frames per second.
|
||||
|
||||
.. versionaddedold:: 2.1.1
|
||||
|
||||
:raises TypeError: if ``time_ms`` is not int or float
|
||||
|
||||
.. ## LayeredDirty.set_timing_threshold ##
|
||||
|
||||
.. ## pygame.sprite.LayeredDirty ##
|
||||
|
||||
.. function:: GroupSingle
|
||||
|
||||
| :sl:`Group container that holds a single sprite.`
|
||||
| :sg:`GroupSingle(sprite=None) -> GroupSingle`
|
||||
|
||||
The GroupSingle container only holds a single Sprite. When a new Sprite is
|
||||
added, the old one is removed.
|
||||
|
||||
There is a special property, ``GroupSingle.sprite``, that accesses the
|
||||
Sprite that this Group contains. It can be None when the Group is empty. The
|
||||
property can also be assigned to add a Sprite into the GroupSingle
|
||||
container.
|
||||
|
||||
.. ## pygame.sprite.GroupSingle ##
|
||||
|
||||
.. function:: spritecollide
|
||||
|
||||
| :sl:`Find sprites in a group that intersect another sprite.`
|
||||
| :sg:`spritecollide(sprite, group, dokill, collided = None) -> Sprite_list`
|
||||
|
||||
Return a list containing all Sprites in a Group that intersect with another
|
||||
Sprite. Intersection is determined by comparing the ``Sprite.rect``
|
||||
attribute of each Sprite.
|
||||
|
||||
The dokill argument is a bool. If set to True, all Sprites that collide will
|
||||
be removed from the Group.
|
||||
|
||||
The collided argument is a callback function used to calculate if two
|
||||
sprites are colliding. it should take two sprites as values, and return a
|
||||
bool value indicating if they are colliding. If collided is not passed, all
|
||||
sprites must have a "rect" value, which is a rectangle of the sprite area,
|
||||
which will be used to calculate the collision.
|
||||
|
||||
collided callables:
|
||||
|
||||
::
|
||||
|
||||
collide_rect, collide_rect_ratio, collide_circle,
|
||||
collide_circle_ratio, collide_mask
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# See if the Sprite block has collided with anything in the Group block_list
|
||||
# The True flag will remove the sprite in block_list
|
||||
blocks_hit_list = pygame.sprite.spritecollide(player, block_list, True)
|
||||
|
||||
# Check the list of colliding sprites, and add one to the score for each one
|
||||
for block in blocks_hit_list:
|
||||
score +=1
|
||||
|
||||
.. ## pygame.sprite.spritecollide ##
|
||||
|
||||
.. function:: collide_rect
|
||||
|
||||
| :sl:`Collision detection between two sprites, using rects.`
|
||||
| :sg:`collide_rect(left, right) -> bool`
|
||||
|
||||
Tests for collision between two sprites. Uses the pygame rect colliderect
|
||||
function to calculate the collision. Intended to be passed as a collided
|
||||
callback function to the \*collide functions. Sprites must have a "rect"
|
||||
attributes.
|
||||
|
||||
.. versionaddedold:: 1.8
|
||||
|
||||
.. ## pygame.sprite.collide_rect ##
|
||||
|
||||
.. function:: collide_rect_ratio
|
||||
|
||||
| :sl:`Collision detection between two sprites, using rects scaled to a ratio.`
|
||||
| :sg:`collide_rect_ratio(ratio) -> collided_callable`
|
||||
|
||||
A callable class that checks for collisions between two sprites, using a
|
||||
scaled version of the sprites rects.
|
||||
|
||||
Is created with a ratio, the instance is then intended to be passed as a
|
||||
collided callback function to the \*collide functions.
|
||||
|
||||
A ratio is a floating point number - 1.0 is the same size, 2.0 is twice as
|
||||
big, and 0.5 is half the size.
|
||||
|
||||
.. versionaddedold:: 1.8.1
|
||||
|
||||
.. ## pygame.sprite.collide_rect_ratio ##
|
||||
|
||||
.. function:: collide_circle
|
||||
|
||||
| :sl:`Collision detection between two sprites, using circles.`
|
||||
| :sg:`collide_circle(left, right) -> bool`
|
||||
|
||||
Tests for collision between two sprites, by testing to see if two circles
|
||||
centered on the sprites overlap. If the sprites have a "radius" attribute,
|
||||
that is used to create the circle, otherwise a circle is created that is big
|
||||
enough to completely enclose the sprites rect as given by the "rect"
|
||||
attribute. Intended to be passed as a collided callback function to the
|
||||
\*collide functions. Sprites must have a "rect" and an optional "radius"
|
||||
attribute.
|
||||
|
||||
.. versionaddedold:: 1.8.1
|
||||
|
||||
.. ## pygame.sprite.collide_circle ##
|
||||
|
||||
.. function:: collide_circle_ratio
|
||||
|
||||
| :sl:`Collision detection between two sprites, using circles scaled to a ratio.`
|
||||
| :sg:`collide_circle_ratio(ratio) -> collided_callable`
|
||||
|
||||
A callable class that checks for collisions between two sprites, using a
|
||||
scaled version of the sprites radius.
|
||||
|
||||
Is created with a floating point ratio, the instance is then intended to be
|
||||
passed as a collided callback function to the \*collide functions.
|
||||
|
||||
A ratio is a floating point number - 1.0 is the same size, 2.0 is twice as
|
||||
big, and 0.5 is half the size.
|
||||
|
||||
The created callable tests for collision between two sprites, by testing to
|
||||
see if two circles centered on the sprites overlap, after scaling the
|
||||
circles radius by the stored ratio. If the sprites have a "radius"
|
||||
attribute, that is used to create the circle, otherwise a circle is created
|
||||
that is big enough to completely enclose the sprites rect as given by the
|
||||
"rect" attribute. Intended to be passed as a collided callback function to
|
||||
the \*collide functions. Sprites must have a "rect" and an optional "radius"
|
||||
attribute.
|
||||
|
||||
.. versionaddedold:: 1.8.1
|
||||
|
||||
.. ## pygame.sprite.collide_circle_ratio ##
|
||||
|
||||
.. function:: collide_mask
|
||||
|
||||
| :sl:`Collision detection between two sprites, using masks.`
|
||||
| :sg:`collide_mask(sprite1, sprite2) -> (int, int)`
|
||||
| :sg:`collide_mask(sprite1, sprite2) -> None`
|
||||
|
||||
Tests for collision between two sprites, by testing if their bitmasks
|
||||
overlap (uses :func:`pygame.mask.Mask.overlap`). If the sprites have a
|
||||
``mask`` attribute, it is used as the mask, otherwise a mask is created from
|
||||
the sprite's ``image`` (uses :func:`pygame.mask.from_surface`). Sprites must
|
||||
have a ``rect`` attribute; the ``mask`` attribute is optional.
|
||||
|
||||
The first point of collision between the masks is returned. The collision
|
||||
point is offset from ``sprite1``'s mask's topleft corner (which is always
|
||||
(0, 0)). The collision point is a position within the mask and is not
|
||||
related to the actual screen position of ``sprite1``.
|
||||
|
||||
This function is intended to be passed as a ``collided`` callback function
|
||||
to the group collide functions (see :meth:`spritecollide`,
|
||||
:meth:`groupcollide`, :meth:`spritecollideany`).
|
||||
|
||||
.. note::
|
||||
To increase performance, create and set a ``mask`` attribute for all
|
||||
sprites that will use this function to check for collisions. Otherwise,
|
||||
each time this function is called it will create new masks.
|
||||
|
||||
.. note::
|
||||
A new mask needs to be recreated each time a sprite's image is changed
|
||||
(e.g. if a new image is used or the existing image is rotated).
|
||||
|
||||
::
|
||||
|
||||
# Example of mask creation for a sprite.
|
||||
sprite.mask = pygame.mask.from_surface(sprite.image)
|
||||
|
||||
:returns: first point of collision between the masks or ``None`` if no
|
||||
collision
|
||||
:rtype: tuple(int, int) or NoneType
|
||||
|
||||
.. versionaddedold:: 1.8.0
|
||||
|
||||
.. ## pygame.sprite.collide_mask ##
|
||||
|
||||
.. function:: groupcollide
|
||||
|
||||
| :sl:`Find all sprites that collide between two groups.`
|
||||
| :sg:`groupcollide(group1, group2, dokill1, dokill2, collided = None) -> Sprite_dict`
|
||||
|
||||
This will find collisions between all the Sprites in two groups.
|
||||
Collision is determined by comparing the ``Sprite.rect`` attribute of
|
||||
each Sprite or by using the collided function if it is not None.
|
||||
|
||||
Every Sprite inside group1 is added to the return dictionary. The value for
|
||||
each item is the list of Sprites in group2 that intersect.
|
||||
|
||||
If either dokill argument is True, the colliding Sprites will be removed
|
||||
from their respective Group.
|
||||
|
||||
The collided argument is a callback function used to calculate if two sprites are
|
||||
colliding. It should take two sprites as values and return a bool value
|
||||
indicating if they are colliding. If collided is not passed, then all
|
||||
sprites must have a "rect" value, which is a rectangle of the sprite area,
|
||||
which will be used to calculate the collision.
|
||||
|
||||
.. ## pygame.sprite.groupcollide ##
|
||||
|
||||
.. function:: spritecollideany
|
||||
|
||||
| :sl:`Simple test if a sprite intersects anything in a group.`
|
||||
| :sg:`spritecollideany(sprite, group, collided = None) -> Sprite` Collision with the returned sprite.
|
||||
| :sg:`spritecollideany(sprite, group, collided = None) -> None` No collision
|
||||
|
||||
If the sprite collides with any single sprite in the group, a single
|
||||
sprite from the group is returned. On no collision None is returned.
|
||||
|
||||
If you don't need all the features of the ``pygame.sprite.spritecollide()`` function, this
|
||||
function will be a bit quicker.
|
||||
|
||||
The collided argument is a callback function used to calculate if two sprites are
|
||||
colliding. It should take two sprites as values and return a bool value
|
||||
indicating if they are colliding. If collided is not passed, then all
|
||||
sprites must have a "rect" value, which is a rectangle of the sprite area,
|
||||
which will be used to calculate the collision.
|
||||
|
||||
.. ## pygame.sprite.spritecollideany ##
|
||||
|
||||
.. ## ##
|
||||
|
||||
.. ## pygame.sprite ##
|
||||
@@ -0,0 +1,10 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.Surface`
|
||||
=====================
|
||||
|
||||
.. currentmodule:: pygame
|
||||
|
||||
.. autopgclass:: Surface
|
||||
:members:
|
||||
:private-members: +_pixels_address
|
||||
@@ -0,0 +1,349 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.surfarray`
|
||||
=======================
|
||||
|
||||
.. module:: pygame.surfarray
|
||||
:synopsis: pygame module for accessing surface pixel data using array interfaces
|
||||
|
||||
| :sl:`pygame module for accessing surface pixel data using array interfaces`
|
||||
|
||||
Functions to convert between NumPy arrays and Surface objects. This module
|
||||
will only be functional when pygame can use the external NumPy package.
|
||||
If NumPy can't be imported, ``surfarray`` becomes a ``MissingModule`` object.
|
||||
|
||||
Every pixel is stored as a single integer value to represent the red, green,
|
||||
and blue colors. The 8-bit images use a value that looks into a colormap. Pixels
|
||||
with higher depth use a bit packing process to place three or four values into
|
||||
a single number.
|
||||
|
||||
The arrays are indexed by the ``X`` axis first, followed by the ``Y`` axis.
|
||||
Arrays that treat the pixels as a single integer are referred to as 2D arrays.
|
||||
This module can also separate the red, green, and blue color values into
|
||||
separate indices. These types of arrays are referred to as 3D arrays, and the
|
||||
last index is 0 for red, 1 for green, and 2 for blue.
|
||||
|
||||
The pixels of a 2D array as returned by :func:`array2d` and :func:`pixels2d`
|
||||
are mapped to the specific surface. Use :meth:`pygame.Surface.unmap_rgb`
|
||||
to convert to a color, and :meth:`pygame.Surface.map_rgb` to get the surface
|
||||
specific pixel value of a color. Integer pixel values can only be used directly
|
||||
between surfaces with matching pixel layouts (see :class:`pygame.Surface`).
|
||||
|
||||
All functions that refer to "array" will copy the surface information to a new
|
||||
NumPy array. All functions that refer to "pixels" will directly reference the
|
||||
pixels from the surface and any changes performed to the array will make changes
|
||||
in the surface. As this last functions share memory with the surface, this one
|
||||
will be locked during the lifetime of the array.
|
||||
|
||||
.. versionchanged:: 2.5.6 surfarray module is lazily loaded to avoid an expensive NumPy import when unnecessary
|
||||
|
||||
.. function:: array2d
|
||||
|
||||
| :sl:`Copy pixels into a 2d array`
|
||||
| :sg:`array2d(Surface) -> array`
|
||||
|
||||
Copy the :meth:`mapped <pygame.Surface.map_rgb>` (raw) pixels from a Surface
|
||||
into a 2D array.
|
||||
The bit depth of the surface will control the size of the integer values,
|
||||
and will work for any type of pixel format.
|
||||
|
||||
This function will temporarily lock the Surface as pixels are copied
|
||||
(see the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method).
|
||||
|
||||
.. ## pygame.surfarray.array2d ##
|
||||
|
||||
.. function:: pixels2d
|
||||
|
||||
| :sl:`Reference pixels into a 2d array`
|
||||
| :sg:`pixels2d(Surface) -> array`
|
||||
|
||||
Create a new 2D array that directly references the pixel values in a
|
||||
Surface. Any changes to the array will affect the pixels in the Surface.
|
||||
This is a fast operation since no data is copied.
|
||||
|
||||
Pixels from a 24-bit Surface cannot be referenced, but all other Surface bit
|
||||
depths can.
|
||||
|
||||
The Surface this references will remain locked for the lifetime of the array,
|
||||
since the array generated by this function shares memory with the surface.
|
||||
See the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method.
|
||||
|
||||
.. ## pygame.surfarray.pixels2d ##
|
||||
|
||||
.. function:: array3d
|
||||
|
||||
| :sl:`Copy pixels into a 3d array`
|
||||
| :sg:`array3d(Surface) -> array`
|
||||
|
||||
Copy the pixels from a Surface into a 3D array. The bit depth of the surface
|
||||
will control the size of the integer values, and will work for any type of
|
||||
pixel format.
|
||||
|
||||
This function will temporarily lock the Surface as pixels are copied (see
|
||||
the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method).
|
||||
|
||||
.. ## pygame.surfarray.array3d ##
|
||||
|
||||
.. function:: pixels3d
|
||||
|
||||
| :sl:`Reference pixels into a 3d array`
|
||||
| :sg:`pixels3d(Surface) -> array`
|
||||
|
||||
Create a new 3D array that directly references the pixel values in a
|
||||
Surface. Any changes to the array will affect the pixels in the Surface.
|
||||
This is a fast operation since no data is copied.
|
||||
|
||||
This will only work on Surfaces that have 24-bit or 32-bit formats. Lower
|
||||
pixel formats cannot be referenced.
|
||||
|
||||
The Surface this references will remain locked for the lifetime of the array,
|
||||
since the array generated by this function shares memory with the surface.
|
||||
See the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method.
|
||||
|
||||
.. ## pygame.surfarray.pixels3d ##
|
||||
|
||||
.. function:: array_alpha
|
||||
|
||||
| :sl:`Copy pixel alphas into a 2d array`
|
||||
| :sg:`array_alpha(Surface) -> array`
|
||||
|
||||
Copy the pixel alpha values (degree of transparency) from a Surface into a
|
||||
2D array. This will work for any type of Surface format. Surfaces without a
|
||||
pixel alpha will return an array with all opaque values.
|
||||
|
||||
This function will temporarily lock the Surface as pixels are copied (see
|
||||
the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method).
|
||||
|
||||
.. ## pygame.surfarray.array_alpha ##
|
||||
|
||||
.. function:: pixels_alpha
|
||||
|
||||
| :sl:`Reference pixel alphas into a 2d array`
|
||||
| :sg:`pixels_alpha(Surface) -> array`
|
||||
|
||||
Create a new 2D array that directly references the alpha values (degree of
|
||||
transparency) in a Surface. Any changes to the array will affect the pixels
|
||||
in the Surface. This is a fast operation since no data is copied.
|
||||
|
||||
This can only work on 32-bit Surfaces with a per-pixel alpha value.
|
||||
|
||||
The Surface this references will remain locked for the lifetime of the array,
|
||||
since the array generated by this function shares memory with the surface.
|
||||
See the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method.
|
||||
|
||||
.. ## pygame.surfarray.pixels_alpha ##
|
||||
|
||||
.. function:: array_red
|
||||
|
||||
| :sl:`Copy red pixels into a 2d array`
|
||||
| :sg:`array_red(Surface) -> array`
|
||||
|
||||
Copy the pixel red values from a Surface into a 2D array. This will work
|
||||
for any type of Surface format.
|
||||
|
||||
This function will temporarily lock the Surface as pixels are copied (see
|
||||
the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method).
|
||||
|
||||
.. versionaddedold:: 2.0.2
|
||||
|
||||
.. ## pygame.surfarray.array_red ##
|
||||
|
||||
.. function:: pixels_red
|
||||
|
||||
| :sl:`Reference pixel red into a 2d array.`
|
||||
| :sg:`pixels_red (Surface) -> array`
|
||||
|
||||
Create a new 2D array that directly references the red values in a Surface.
|
||||
Any changes to the array will affect the pixels in the Surface. This is a
|
||||
fast operation since no data is copied.
|
||||
|
||||
This can only work on 24-bit or 32-bit Surfaces.
|
||||
|
||||
The Surface this references will remain locked for the lifetime of the array,
|
||||
since the array generated by this function shares memory with the surface.
|
||||
See the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method.
|
||||
|
||||
.. ## pygame.surfarray.pixels_red ##
|
||||
|
||||
.. function:: array_green
|
||||
|
||||
| :sl:`Copy green pixels into a 2d array`
|
||||
| :sg:`array_green(Surface) -> array`
|
||||
|
||||
Copy the pixel green values from a Surface into a 2D array. This will work
|
||||
for any type of Surface format.
|
||||
|
||||
This function will temporarily lock the Surface as pixels are copied (see
|
||||
the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method).
|
||||
|
||||
.. versionaddedold:: 2.0.2
|
||||
|
||||
.. ## pygame.surfarray.array_green ##
|
||||
|
||||
.. function:: pixels_green
|
||||
|
||||
| :sl:`Reference pixel green into a 2d array.`
|
||||
| :sg:`pixels_green (Surface) -> array`
|
||||
|
||||
Create a new 2D array that directly references the green values in a
|
||||
Surface. Any changes to the array will affect the pixels in the Surface.
|
||||
This is a fast operation since no data is copied.
|
||||
|
||||
This can only work on 24-bit or 32-bit Surfaces.
|
||||
|
||||
The Surface this references will remain locked for the lifetime of the array,
|
||||
since the array generated by this function shares memory with the surface.
|
||||
See the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method.
|
||||
|
||||
.. ## pygame.surfarray.pixels_green ##
|
||||
|
||||
.. function:: array_blue
|
||||
|
||||
| :sl:`Copy blue pixels into a 2d array`
|
||||
| :sg:`array_blue(Surface) -> array`
|
||||
|
||||
Copy the pixel blue values from a Surface into a 2D array. This will work
|
||||
for any type of Surface format.
|
||||
|
||||
This function will temporarily lock the Surface as pixels are copied (see
|
||||
the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method).
|
||||
|
||||
.. versionaddedold:: 2.0.2
|
||||
|
||||
.. ## pygame.surfarray.array_blue ##
|
||||
|
||||
.. function:: pixels_blue
|
||||
|
||||
| :sl:`Reference pixel blue into a 2d array.`
|
||||
| :sg:`pixels_blue (Surface) -> array`
|
||||
|
||||
Create a new 2D array that directly references the blue values in a Surface.
|
||||
Any changes to the array will affect the pixels in the Surface. This is a
|
||||
fast operation since no data is copied.
|
||||
|
||||
This can only work on 24-bit or 32-bit Surfaces.
|
||||
|
||||
The Surface this references will remain locked for the lifetime of the array,
|
||||
since the array generated by this function shares memory with the surface.
|
||||
See the :meth:`pygame.Surface.lock` - lock the Surface memory for pixel
|
||||
access method.
|
||||
|
||||
.. ## pygame.surfarray.pixels_blue ##
|
||||
|
||||
.. function:: array_colorkey
|
||||
|
||||
| :sl:`Copy the colorkey values into a 2d array`
|
||||
| :sg:`array_colorkey(Surface) -> array`
|
||||
|
||||
Create a new array with the colorkey transparency value from each pixel. If
|
||||
the pixel matches the colorkey it will be fully transparent; otherwise it
|
||||
will be fully opaque.
|
||||
|
||||
This will work on any type of Surface format. If the image has no colorkey a
|
||||
solid opaque array will be returned.
|
||||
|
||||
This function will temporarily lock the Surface as pixels are copied.
|
||||
|
||||
.. ## pygame.surfarray.array_colorkey ##
|
||||
|
||||
.. function:: make_surface
|
||||
|
||||
| :sl:`Copy an array to a new surface`
|
||||
| :sg:`make_surface(array) -> Surface`
|
||||
|
||||
Create a new Surface that best resembles the data and format on the array.
|
||||
The array can be 2D or 3D with any sized integer values. Function
|
||||
make_surface uses the array struct interface to acquire array properties,
|
||||
so is not limited to just NumPy arrays. See :mod:`pygame.pixelcopy`.
|
||||
|
||||
``float32``, ``float64`` and (where available) ``float96`` NumPy arrays
|
||||
are also accepted, but are first rounded to the nearest integer and
|
||||
copied into a new array before creating the surface.
|
||||
|
||||
New in pygame 1.9.2: array struct interface support.
|
||||
|
||||
.. ## pygame.surfarray.make_surface ##
|
||||
|
||||
.. function:: blit_array
|
||||
|
||||
| :sl:`Blit directly from a array values`
|
||||
| :sg:`blit_array(Surface, array) -> None`
|
||||
|
||||
Directly copy values from an array into a Surface. This is faster than
|
||||
converting the array into a Surface and blitting. The array must be the same
|
||||
dimensions as the Surface and will completely replace all pixel values.
|
||||
Accepted array types are integer, ASCII character and record arrays, as
|
||||
well as ``float32``, ``float64`` and (where available) ``float96`` NumPy
|
||||
arrays.
|
||||
|
||||
Float arrays are first rounded to the nearest integer and copied into
|
||||
a new array before blitting. This is significantly slower (on the order of 2x)
|
||||
versus passing an integer array.
|
||||
|
||||
This function will temporarily lock the Surface as the new values are
|
||||
copied.
|
||||
|
||||
.. ## pygame.surfarray.blit_array ##
|
||||
|
||||
.. function:: map_array
|
||||
|
||||
| :sl:`Map a 3d array into a 2d array`
|
||||
| :sg:`map_array(Surface, array3d) -> array2d`
|
||||
|
||||
Convert a 3D array into a 2D array. This will use the given Surface format
|
||||
to control the conversion. Palette surface formats are supported for NumPy
|
||||
arrays.
|
||||
|
||||
.. ## pygame.surfarray.map_array ##
|
||||
|
||||
.. function:: use_arraytype
|
||||
|
||||
| :sl:`Sets the array system to be used for surface arrays`
|
||||
| :sg:`use_arraytype (arraytype) -> None`
|
||||
|
||||
DEPRECATED: Uses the requested array type for the module functions.
|
||||
The only supported arraytype is ``'numpy'``. Other values will raise
|
||||
ValueError. Using this function will raise a ``DeprecationWarning``.
|
||||
|
||||
.. ## pygame.surfarray.use_arraytype ##
|
||||
|
||||
.. function:: get_arraytype
|
||||
|
||||
| :sl:`Gets the currently active array type.`
|
||||
| :sg:`get_arraytype () -> str`
|
||||
|
||||
DEPRECATED: Returns the currently active array type. This will be a value of the
|
||||
``get_arraytypes()`` tuple and indicates which type of array module is used
|
||||
for the array creation. Using this function will raise a ``DeprecationWarning``.
|
||||
|
||||
.. versionaddedold:: 1.8
|
||||
|
||||
.. ## pygame.surfarray.get_arraytype ##
|
||||
|
||||
.. function:: get_arraytypes
|
||||
|
||||
| :sl:`Gets the array system types currently supported.`
|
||||
| :sg:`get_arraytypes () -> tuple`
|
||||
|
||||
DEPRECATED: Checks, which array systems are available and returns them as a tuple of
|
||||
strings. The values of the tuple can be used directly in the
|
||||
:func:`pygame.surfarray.use_arraytype` () method. If no supported array
|
||||
system could be found, None will be returned. Using this function will raise a
|
||||
``DeprecationWarning``.
|
||||
|
||||
.. versionaddedold:: 1.8
|
||||
|
||||
.. ## pygame.surfarray.get_arraytypes ##
|
||||
|
||||
.. ## pygame.surfarray ##
|
||||
@@ -0,0 +1,7 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.system`
|
||||
====================
|
||||
|
||||
.. autopgmodule:: pygame.system
|
||||
:members:
|
||||
@@ -0,0 +1,108 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.tests`
|
||||
===================
|
||||
|
||||
.. module:: pygame.tests
|
||||
:synopsis: Pygame unit test suite package
|
||||
|
||||
| :sl:`Pygame unit test suite package`
|
||||
|
||||
A quick way to run the test suite package from the command line is to import
|
||||
the go submodule with the Python -m option:
|
||||
|
||||
::
|
||||
|
||||
python -m pygame.tests [<test options>]
|
||||
|
||||
Command line option --help displays a usage message. Available options
|
||||
correspond to the :func:`pygame.tests.run` arguments.
|
||||
|
||||
The xxxx_test submodules of the tests package are unit test suites for
|
||||
individual parts of pygame. Each can also be run as a main program. This is
|
||||
useful if the test is interactive.
|
||||
|
||||
For pygame development the test suite can be run from a pygame distribution
|
||||
root directory. Program ``run_tests.py`` is provided for convenience, though
|
||||
test/go.py can be run directly.
|
||||
|
||||
Module level tags control which modules are included in a unit test run. Tags
|
||||
are assigned to a unit test module with a corresponding <name>_tags.py module.
|
||||
The tags module has the global __tags__, a list of tag names. For example,
|
||||
``controller_test.py`` has a tag variable containing a tags list that
|
||||
has the 'interactive' string. The 'interactive' tag indicates ``controller_test.py``
|
||||
expects user input. It is excluded from a ``run_tests.py`` or
|
||||
``pygame.tests.go`` run. Two other tags that are excluded are 'ignore' and
|
||||
'subprocess_ignore'. These two tags indicate unit tests that will not run on a
|
||||
particular platform, or for which no corresponding pygame module is available.
|
||||
The test runner will list each excluded module along with the tag responsible.
|
||||
|
||||
.. function:: run
|
||||
|
||||
| :sl:`Run the pygame unit test suite`
|
||||
| :sg:`run(*args, **kwds) -> tuple`
|
||||
|
||||
Positional arguments (optional):
|
||||
|
||||
::
|
||||
|
||||
The names of tests to include. If omitted then all tests are run. Test names
|
||||
need not include the trailing '_test'.
|
||||
|
||||
Keyword arguments:
|
||||
|
||||
::
|
||||
|
||||
incomplete - fail incomplete tests (default False)
|
||||
nosubprocess - run all test suites in the current process
|
||||
(default False, use separate subprocesses)
|
||||
dump - dump failures/errors as dict ready to eval (default False)
|
||||
file - if provided, the name of a file into which to dump failures/errors
|
||||
timings - if provided, the number of times to run each individual test to
|
||||
get an average run time (default is run each test once)
|
||||
exclude - A list of TAG names to exclude from the run
|
||||
show_output - show silenced stderr/stdout on errors (default False)
|
||||
all - dump all results, not just errors (default False)
|
||||
randomize - randomize order of tests (default False)
|
||||
seed - if provided, a seed randomizer integer
|
||||
multi_thread - if provided, the number of THREADS in which to run
|
||||
subprocessed tests
|
||||
time_out - if subprocess is True then the time limit in seconds before
|
||||
killing a test (default 30)
|
||||
fake - if provided, the name of the fake tests package in the
|
||||
run_tests__tests subpackage to run instead of the normal
|
||||
pygame tests
|
||||
python - the path to a python executable to run subprocessed tests
|
||||
(default sys.executable)
|
||||
|
||||
Return value:
|
||||
|
||||
::
|
||||
|
||||
A tuple of total number of tests run, dictionary of error information.
|
||||
The dictionary is empty if no errors were recorded.
|
||||
|
||||
By default individual test modules are run in separate subprocesses. This
|
||||
recreates normal pygame usage where ``pygame.init()`` and ``pygame.quit()``
|
||||
are called only once per program execution, and avoids unfortunate
|
||||
interactions between test modules. Also, a time limit is placed on test
|
||||
execution, so frozen tests are killed when their time allotment expired. Use
|
||||
the single process option if threading is not working properly or if tests
|
||||
are taking too long. It is not guaranteed that all tests will pass in single
|
||||
process mode.
|
||||
|
||||
Tests are run in a randomized order if the randomize argument is True or a
|
||||
seed argument is provided. If no seed integer is provided then the system
|
||||
time is used.
|
||||
|
||||
Individual test modules may have a __tags__ attribute, a list of tag strings
|
||||
used to selectively omit modules from a run. By default only 'interactive'
|
||||
modules such as controller_test are ignored. An interactive module must be run
|
||||
from the console as a Python program.
|
||||
|
||||
This function can only be called once per Python session. It is not
|
||||
reentrant.
|
||||
|
||||
.. ## pygame.tests.run ##
|
||||
|
||||
.. ## pygame.tests ##
|
||||
@@ -0,0 +1,7 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.time`
|
||||
==================
|
||||
|
||||
.. autopgmodule:: pygame.time
|
||||
:members:
|
||||
@@ -0,0 +1,67 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame._sdl2.touch`
|
||||
=========================
|
||||
|
||||
.. module:: pygame._sdl2.touch
|
||||
:synopsis: pygame module to work with touch input
|
||||
|
||||
| :sl:`pygame module to work with touch input`
|
||||
|
||||
.. versionaddedold:: 2 This module requires SDL2.
|
||||
|
||||
.. function:: get_num_devices
|
||||
|
||||
| :sl:`get the number of touch devices`
|
||||
| :sg:`get_num_devices() -> int`
|
||||
|
||||
Return the number of available touch devices.
|
||||
|
||||
.. ## pygame._sdl2.touch.get_num_devices ##
|
||||
|
||||
.. function:: get_device
|
||||
|
||||
| :sl:`get the a touch device id for a given index`
|
||||
| :sg:`get_device(index) -> touchid`
|
||||
|
||||
:param int index: This number is at least 0 and less than the
|
||||
:func:`number of devices <pygame._sdl2.touch.get_num_devices()>`.
|
||||
|
||||
Return an integer id associated with the given ``index``.
|
||||
|
||||
.. ## pygame._sdl2.touch.get_device ##
|
||||
|
||||
.. function:: get_num_fingers
|
||||
|
||||
| :sl:`the number of active fingers for a given touch device`
|
||||
| :sg:`get_num_fingers(touchid) -> int`
|
||||
|
||||
Return the number of fingers active for the touch device
|
||||
whose id is `touchid`.
|
||||
|
||||
.. ## pygame._sdl2.touch.get_num_fingers ##
|
||||
|
||||
.. function:: get_finger
|
||||
|
||||
| :sl:`get information about an active finger`
|
||||
| :sg:`get_finger(touchid, index) -> dict | None`
|
||||
|
||||
:param int touchid: The touch device id.
|
||||
:param int index: The index of the finger to return
|
||||
information about, between 0 and the
|
||||
:func:`number of active fingers <pygame._sdl2.touch.get_num_fingers()>`.
|
||||
|
||||
Return a dict for the finger ``index`` active on ``touchid``, or ``None`` if the
|
||||
object does not exist.
|
||||
The dict contains these keys:
|
||||
|
||||
::
|
||||
|
||||
id the id of the finger (an integer).
|
||||
x the normalized x position of the finger, between 0 and 1.
|
||||
y the normalized y position of the finger, between 0 and 1.
|
||||
pressure the amount of pressure applied by the finger, between 0 and 1.
|
||||
|
||||
.. ## pygame._sdl2.touch.get_finger ##
|
||||
|
||||
.. ## pygame._sdl2.touch ##
|
||||
@@ -0,0 +1,7 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.transform`
|
||||
=======================
|
||||
|
||||
.. autopgmodule:: pygame.transform
|
||||
:members:
|
||||
@@ -0,0 +1,79 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.typing`
|
||||
====================
|
||||
|
||||
.. module:: pygame.typing
|
||||
:synopsis: pygame module providing common typehints
|
||||
|
||||
| :sl:`pygame module providing common typehints`
|
||||
|
||||
.. versionadded:: 2.5.2
|
||||
|
||||
A lot of pygame functions and methods allow the user to provide different types
|
||||
for the same value like colors or points. This module exports the most common
|
||||
type aliases for proper typehint annotations.
|
||||
|
||||
.. data:: FileLike
|
||||
|
||||
An object representing a file. This includes both path-like
|
||||
objects and file-like objects, i.e.:
|
||||
|
||||
* ``"my/string/path.txt"``
|
||||
* ``open("my/file/path.txt")``
|
||||
* ``pathlib.Path("my/pathlib/path.txt")``
|
||||
* ``io.BytesIO(b"my data: \x00\x01")``
|
||||
* ``b"my/bytes/path.txt"``
|
||||
* Any object implementing the path protocol or file protocol.
|
||||
|
||||
.. data:: SequenceLike
|
||||
|
||||
A variant of the standard ``Sequence`` ABC only requiring ``__getitem__``
|
||||
and ``__len__``. This includes custom sequences or builtin ones, i.e.:
|
||||
|
||||
* ``"abcdefg"``
|
||||
* ``[a, b, c, d, ...]``
|
||||
* ``(a, b, c, d, ...)``
|
||||
|
||||
Being a generic, subscribing it will signal further precision such as
|
||||
``SequenceLike[str]`` or ``SequenceLike[float]``.
|
||||
|
||||
.. data:: Point
|
||||
|
||||
A sequence of two numbers (floats or ints), i.e:
|
||||
|
||||
* ``pygame.Vector2(a, b)``
|
||||
* ``[a, b]``
|
||||
* ``(a, b)``
|
||||
|
||||
.. data:: IntPoint
|
||||
|
||||
A sequence of strictly two integers such as ``[a, b]`` or ``(a, b)``.
|
||||
|
||||
.. data:: ColorLike
|
||||
|
||||
An object representing a color such as a mapped integer, a string or
|
||||
a sequence of three or four integers in range 0-255, types supported by
|
||||
every function accepting a color argument. i.e.:
|
||||
|
||||
* ``pygame.Color(ColorLike)``
|
||||
* ``(r, g, b)``
|
||||
* ``(r, g, b, a)``
|
||||
* ``[r, g, b, a]``
|
||||
* ``"green"`` (:doc:`color_list`)
|
||||
* ``"#rrggbbaa"``
|
||||
* ``0`` (mapped color)
|
||||
|
||||
.. data:: RectLike
|
||||
|
||||
An object representing a rect such as a sequence of numbers or points
|
||||
or an object with a rect attribute or a method returning a rect. These types
|
||||
are supported by every function accepting a rect as argument. i.e.:
|
||||
|
||||
* ``(x, y, w, h)``
|
||||
* ``(Point, Point)``
|
||||
* ``pygame.Rect(RectLike)``
|
||||
* Any object with a ``.rect`` attribute which is a ``RectLike`` or a function
|
||||
returning a ``RectLike``
|
||||
|
||||
.. ## pygame.typing ##
|
||||
@@ -0,0 +1,9 @@
|
||||
.. include:: common.txt
|
||||
|
||||
:mod:`pygame.Window`
|
||||
=====================
|
||||
|
||||
.. currentmodule:: pygame
|
||||
|
||||
.. autopgclass:: pygame.Window
|
||||
:members:
|
||||
@@ -0,0 +1,914 @@
|
||||
/*
|
||||
* Sphinx stylesheet -- basic theme.
|
||||
*/
|
||||
|
||||
/* -- main layout ----------------------------------------------------------- */
|
||||
|
||||
div.clearer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
div.section::after {
|
||||
display: block;
|
||||
content: '';
|
||||
clear: left;
|
||||
}
|
||||
|
||||
/* -- relbar ---------------------------------------------------------------- */
|
||||
|
||||
div.related {
|
||||
width: 100%;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
div.related h3 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.related ul {
|
||||
margin: 0;
|
||||
padding: 0 0 0 10px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
div.related li {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
div.related li.right {
|
||||
float: right;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/* -- sidebar --------------------------------------------------------------- */
|
||||
|
||||
div.sphinxsidebarwrapper {
|
||||
padding: 10px 5px 0 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
float: left;
|
||||
width: 230px;
|
||||
margin-left: -100%;
|
||||
font-size: 90%;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap : break-word;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul ul,
|
||||
div.sphinxsidebar ul.want-points {
|
||||
margin-left: 20px;
|
||||
list-style: square;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul ul {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar form {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #98dbcc;
|
||||
font-family: sans-serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox form.search {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="text"] {
|
||||
float: left;
|
||||
width: 80%;
|
||||
padding: 0.25em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="submit"] {
|
||||
float: left;
|
||||
width: 20%;
|
||||
border-left: none;
|
||||
padding: 0.25em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* -- search page ----------------------------------------------------------- */
|
||||
|
||||
ul.search {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
ul.search li {
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
ul.search li a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul.search li p.context {
|
||||
color: #888;
|
||||
margin: 2px 0 0 30px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
ul.keywordmatches li.goodmatch a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* -- index page ------------------------------------------------------------ */
|
||||
|
||||
table.contentstable {
|
||||
width: 90%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.contentstable p.biglink {
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
a.biglink {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
span.linkdescr {
|
||||
font-style: italic;
|
||||
padding-top: 5px;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
/* -- general index --------------------------------------------------------- */
|
||||
|
||||
table.indextable {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.indextable td {
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
table.indextable ul {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
table.indextable > tbody > tr > td > ul {
|
||||
padding-left: 0em;
|
||||
}
|
||||
|
||||
table.indextable tr.pcap {
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
table.indextable tr.cap {
|
||||
margin-top: 10px;
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
img.toggler {
|
||||
margin-right: 3px;
|
||||
margin-top: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
div.modindex-jumpbox {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin: 1em 0 1em 0;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
div.genindex-jumpbox {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin: 1em 0 1em 0;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
/* -- domain module index --------------------------------------------------- */
|
||||
|
||||
table.modindextable td {
|
||||
padding: 2px;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
/* -- general body styles --------------------------------------------------- */
|
||||
|
||||
div.body {
|
||||
min-width: 360px;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
div.body p, div.body dd, div.body li, div.body blockquote {
|
||||
-moz-hyphens: auto;
|
||||
-ms-hyphens: auto;
|
||||
-webkit-hyphens: auto;
|
||||
hyphens: auto;
|
||||
}
|
||||
|
||||
a.headerlink {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #551A8B;
|
||||
}
|
||||
|
||||
h1:hover > a.headerlink,
|
||||
h2:hover > a.headerlink,
|
||||
h3:hover > a.headerlink,
|
||||
h4:hover > a.headerlink,
|
||||
h5:hover > a.headerlink,
|
||||
h6:hover > a.headerlink,
|
||||
dt:hover > a.headerlink,
|
||||
caption:hover > a.headerlink,
|
||||
p.caption:hover > a.headerlink,
|
||||
div.code-block-caption:hover > a.headerlink {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
div.body p.caption {
|
||||
text-align: inherit;
|
||||
}
|
||||
|
||||
div.body td {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.first {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
p.rubric {
|
||||
margin-top: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
img.align-left, figure.align-left, .figure.align-left, object.align-left {
|
||||
clear: left;
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
img.align-right, figure.align-right, .figure.align-right, object.align-right {
|
||||
clear: right;
|
||||
float: right;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
img.align-center, figure.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
img.align-default, figure.align-default, .figure.align-default {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.align-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.align-default {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.align-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* -- sidebars -------------------------------------------------------------- */
|
||||
|
||||
div.sidebar,
|
||||
aside.sidebar {
|
||||
margin: 0 0 0.5em 1em;
|
||||
border: 1px solid #ddb;
|
||||
padding: 7px;
|
||||
background-color: #ffe;
|
||||
width: 40%;
|
||||
float: right;
|
||||
clear: right;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
p.sidebar-title {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
nav.contents,
|
||||
aside.topic,
|
||||
div.admonition, div.topic, blockquote {
|
||||
clear: left;
|
||||
}
|
||||
|
||||
/* -- topics ---------------------------------------------------------------- */
|
||||
|
||||
nav.contents,
|
||||
aside.topic,
|
||||
div.topic {
|
||||
border: 1px solid #ccc;
|
||||
padding: 7px;
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
p.topic-title {
|
||||
font-size: 1.1em;
|
||||
font-weight: bold;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* -- admonitions ----------------------------------------------------------- */
|
||||
|
||||
div.admonition {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
div.admonition dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
p.admonition-title {
|
||||
margin: 0px 10px 5px 0px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.body p.centered {
|
||||
text-align: center;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
/* -- content of sidebars/topics/admonitions -------------------------------- */
|
||||
|
||||
div.sidebar > :last-child,
|
||||
aside.sidebar > :last-child,
|
||||
nav.contents > :last-child,
|
||||
aside.topic > :last-child,
|
||||
div.topic > :last-child,
|
||||
div.admonition > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.sidebar::after,
|
||||
aside.sidebar::after,
|
||||
nav.contents::after,
|
||||
aside.topic::after,
|
||||
div.topic::after,
|
||||
div.admonition::after,
|
||||
blockquote::after {
|
||||
display: block;
|
||||
content: '';
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* -- tables ---------------------------------------------------------------- */
|
||||
|
||||
table.docutils {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
border: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-default {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table caption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
table caption span.caption-text {
|
||||
}
|
||||
|
||||
table.docutils td, table.docutils th {
|
||||
padding: 1px 8px 1px 5px;
|
||||
border-top: 0;
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
table.citation td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
th > :first-child,
|
||||
td > :first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
th > :last-child,
|
||||
td > :last-child {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
/* -- figures --------------------------------------------------------------- */
|
||||
|
||||
div.figure, figure {
|
||||
margin: 0.5em;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
div.figure p.caption, figcaption {
|
||||
padding: 0.3em;
|
||||
}
|
||||
|
||||
div.figure p.caption span.caption-number,
|
||||
figcaption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.figure p.caption span.caption-text,
|
||||
figcaption span.caption-text {
|
||||
}
|
||||
|
||||
/* -- field list styles ----------------------------------------------------- */
|
||||
|
||||
table.field-list td, table.field-list th {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
.field-list ul {
|
||||
margin: 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.field-list p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.field-name {
|
||||
-moz-hyphens: manual;
|
||||
-ms-hyphens: manual;
|
||||
-webkit-hyphens: manual;
|
||||
hyphens: manual;
|
||||
}
|
||||
|
||||
/* -- hlist styles ---------------------------------------------------------- */
|
||||
|
||||
table.hlist {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
table.hlist td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
/* -- object description styles --------------------------------------------- */
|
||||
|
||||
.sig {
|
||||
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
||||
}
|
||||
|
||||
.sig-name, code.descname {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.sig-name {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
code.descname {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.sig-prename, code.descclassname {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.optional {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.sig-paren {
|
||||
font-size: larger;
|
||||
}
|
||||
|
||||
.sig-param.n {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* C++ specific styling */
|
||||
|
||||
.sig-inline.c-texpr,
|
||||
.sig-inline.cpp-texpr {
|
||||
font-family: unset;
|
||||
}
|
||||
|
||||
.sig.c .k, .sig.c .kt,
|
||||
.sig.cpp .k, .sig.cpp .kt {
|
||||
color: #0033B3;
|
||||
}
|
||||
|
||||
.sig.c .m,
|
||||
.sig.cpp .m {
|
||||
color: #1750EB;
|
||||
}
|
||||
|
||||
.sig.c .s, .sig.c .sc,
|
||||
.sig.cpp .s, .sig.cpp .sc {
|
||||
color: #067D17;
|
||||
}
|
||||
|
||||
|
||||
/* -- other body styles ----------------------------------------------------- */
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal;
|
||||
}
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha;
|
||||
}
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha;
|
||||
}
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman;
|
||||
}
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman;
|
||||
}
|
||||
|
||||
:not(li) > ol > li:first-child > :first-child,
|
||||
:not(li) > ul > li:first-child > :first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
:not(li) > ol > li:last-child > :last-child,
|
||||
:not(li) > ul > li:last-child > :last-child {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
ol.simple ol p,
|
||||
ol.simple ul p,
|
||||
ul.simple ol p,
|
||||
ul.simple ul p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
ol.simple > li:not(:first-child) > p,
|
||||
ul.simple > li:not(:first-child) > p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
ol.simple p,
|
||||
ul.simple p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
aside.footnote > span,
|
||||
div.citation > span {
|
||||
float: left;
|
||||
}
|
||||
aside.footnote > span:last-of-type,
|
||||
div.citation > span:last-of-type {
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
aside.footnote > p {
|
||||
margin-left: 2em;
|
||||
}
|
||||
div.citation > p {
|
||||
margin-left: 4em;
|
||||
}
|
||||
aside.footnote > p:last-of-type,
|
||||
div.citation > p:last-of-type {
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
aside.footnote > p:last-of-type:after,
|
||||
div.citation > p:last-of-type:after {
|
||||
content: "";
|
||||
clear: both;
|
||||
}
|
||||
|
||||
dl.field-list {
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(30%) auto;
|
||||
}
|
||||
|
||||
dl.field-list > dt {
|
||||
font-weight: bold;
|
||||
word-break: break-word;
|
||||
padding-left: 0.5em;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
dl.field-list > dd {
|
||||
padding-left: 0.5em;
|
||||
margin-top: 0em;
|
||||
margin-left: 0em;
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
dd > :first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
dd ul, dd table {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 10px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
.sig dd {
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.sig dl {
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
dl > dd:last-child,
|
||||
dl > dd:last-child > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
dt:target, span.highlighted {
|
||||
background-color: #fbe54e;
|
||||
}
|
||||
|
||||
rect.highlighted {
|
||||
fill: #fbe54e;
|
||||
}
|
||||
|
||||
dl.glossary dt {
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.versionmodified {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.system-message {
|
||||
background-color: #fda;
|
||||
padding: 5px;
|
||||
border: 3px solid red;
|
||||
}
|
||||
|
||||
.footnote:target {
|
||||
background-color: #ffa;
|
||||
}
|
||||
|
||||
.line-block {
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.line-block .line-block {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
.guilabel, .menuselection {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.accelerator {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.classifier {
|
||||
font-style: oblique;
|
||||
}
|
||||
|
||||
.classifier:before {
|
||||
font-style: normal;
|
||||
margin: 0 0.5em;
|
||||
content: ":";
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
abbr, acronym {
|
||||
border-bottom: dotted 1px;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.translated {
|
||||
background-color: rgba(207, 255, 207, 0.2)
|
||||
}
|
||||
|
||||
.untranslated {
|
||||
background-color: rgba(255, 207, 207, 0.2)
|
||||
}
|
||||
|
||||
/* -- code displays --------------------------------------------------------- */
|
||||
|
||||
pre {
|
||||
overflow: auto;
|
||||
overflow-y: hidden; /* fixes display issues on Chrome browsers */
|
||||
}
|
||||
|
||||
pre, div[class*="highlight-"] {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
span.pre {
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
-webkit-hyphens: none;
|
||||
hyphens: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
div[class*="highlight-"] {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
td.linenos pre {
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
table.highlighttable {
|
||||
display: block;
|
||||
}
|
||||
|
||||
table.highlighttable tbody {
|
||||
display: block;
|
||||
}
|
||||
|
||||
table.highlighttable tr {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
table.highlighttable td {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
table.highlighttable td.linenos {
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
table.highlighttable td.code {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.highlight .hll {
|
||||
display: block;
|
||||
}
|
||||
|
||||
div.highlight pre,
|
||||
table.highlighttable pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.code-block-caption + div {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
div.code-block-caption {
|
||||
margin-top: 1em;
|
||||
padding: 2px 5px;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
div.code-block-caption code {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
table.highlighttable td.linenos,
|
||||
span.linenos,
|
||||
div.highlight span.gp { /* gp: Generic.Prompt */
|
||||
user-select: none;
|
||||
-webkit-user-select: text; /* Safari fallback only */
|
||||
-webkit-user-select: none; /* Chrome/Safari */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* IE10+ */
|
||||
}
|
||||
|
||||
div.code-block-caption span.caption-number {
|
||||
padding: 0.1em 0.3em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.code-block-caption span.caption-text {
|
||||
}
|
||||
|
||||
div.literal-block-wrapper {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
code.xref, a code {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.viewcode-link {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.viewcode-back {
|
||||
float: right;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
div.viewcode-block:target {
|
||||
margin: -1px -10px;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
/* -- math display ---------------------------------------------------------- */
|
||||
|
||||
img.math {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
div.body div.math p {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
span.eqno {
|
||||
float: right;
|
||||
}
|
||||
|
||||
span.eqno a.headerlink {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
div.math:hover a.headerlink {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
/* -- printout stylesheet --------------------------------------------------- */
|
||||
|
||||
@media print {
|
||||
div.document,
|
||||
div.documentwrapper,
|
||||
div.bodywrapper {
|
||||
margin: 0 !important;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.sphinxsidebar,
|
||||
div.related,
|
||||
div.footer,
|
||||
#top-link {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg class="theme-icon" style="fill:#00ba10;" data-theme="dark-theme" version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||
<path d="M10.895 7.574c0 7.55 5.179 13.67 11.567 13.67 1.588 0 3.101-0.38 4.479-1.063-1.695 4.46-5.996 7.636-11.051 7.636-6.533 0-11.83-5.297-11.83-11.83 0-4.82 2.888-8.959 7.023-10.803-0.116 0.778-0.188 1.573-0.188 2.39z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 404 B |
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Base JavaScript utilities for all Sphinx HTML documentation.
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([
|
||||
"TEXTAREA",
|
||||
"INPUT",
|
||||
"SELECT",
|
||||
"BUTTON",
|
||||
]);
|
||||
|
||||
const _ready = (callback) => {
|
||||
if (document.readyState !== "loading") {
|
||||
callback();
|
||||
} else {
|
||||
document.addEventListener("DOMContentLoaded", callback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Small JavaScript module for the documentation.
|
||||
*/
|
||||
const Documentation = {
|
||||
init: () => {
|
||||
Documentation.initDomainIndexTable();
|
||||
Documentation.initOnKeyListeners();
|
||||
},
|
||||
|
||||
/**
|
||||
* i18n support
|
||||
*/
|
||||
TRANSLATIONS: {},
|
||||
PLURAL_EXPR: (n) => (n === 1 ? 0 : 1),
|
||||
LOCALE: "unknown",
|
||||
|
||||
// gettext and ngettext don't access this so that the functions
|
||||
// can safely bound to a different name (_ = Documentation.gettext)
|
||||
gettext: (string) => {
|
||||
const translated = Documentation.TRANSLATIONS[string];
|
||||
switch (typeof translated) {
|
||||
case "undefined":
|
||||
return string; // no translation
|
||||
case "string":
|
||||
return translated; // translation exists
|
||||
default:
|
||||
return translated[0]; // (singular, plural) translation tuple exists
|
||||
}
|
||||
},
|
||||
|
||||
ngettext: (singular, plural, n) => {
|
||||
const translated = Documentation.TRANSLATIONS[singular];
|
||||
if (typeof translated !== "undefined")
|
||||
return translated[Documentation.PLURAL_EXPR(n)];
|
||||
return n === 1 ? singular : plural;
|
||||
},
|
||||
|
||||
addTranslations: (catalog) => {
|
||||
Object.assign(Documentation.TRANSLATIONS, catalog.messages);
|
||||
Documentation.PLURAL_EXPR = new Function(
|
||||
"n",
|
||||
`return (${catalog.plural_expr})`
|
||||
);
|
||||
Documentation.LOCALE = catalog.locale;
|
||||
},
|
||||
|
||||
/**
|
||||
* helper function to focus on search bar
|
||||
*/
|
||||
focusSearchBar: () => {
|
||||
document.querySelectorAll("input[name=q]")[0]?.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialise the domain index toggle buttons
|
||||
*/
|
||||
initDomainIndexTable: () => {
|
||||
const toggler = (el) => {
|
||||
const idNumber = el.id.substr(7);
|
||||
const toggledRows = document.querySelectorAll(`tr.cg-${idNumber}`);
|
||||
if (el.src.substr(-9) === "minus.png") {
|
||||
el.src = `${el.src.substr(0, el.src.length - 9)}plus.png`;
|
||||
toggledRows.forEach((el) => (el.style.display = "none"));
|
||||
} else {
|
||||
el.src = `${el.src.substr(0, el.src.length - 8)}minus.png`;
|
||||
toggledRows.forEach((el) => (el.style.display = ""));
|
||||
}
|
||||
};
|
||||
|
||||
const togglerElements = document.querySelectorAll("img.toggler");
|
||||
togglerElements.forEach((el) =>
|
||||
el.addEventListener("click", (event) => toggler(event.currentTarget))
|
||||
);
|
||||
togglerElements.forEach((el) => (el.style.display = ""));
|
||||
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler);
|
||||
},
|
||||
|
||||
initOnKeyListeners: () => {
|
||||
// only install a listener if it is really needed
|
||||
if (
|
||||
!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS &&
|
||||
!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS
|
||||
)
|
||||
return;
|
||||
|
||||
document.addEventListener("keydown", (event) => {
|
||||
// bail for input elements
|
||||
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
|
||||
// bail with special keys
|
||||
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
||||
|
||||
if (!event.shiftKey) {
|
||||
switch (event.key) {
|
||||
case "ArrowLeft":
|
||||
if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break;
|
||||
|
||||
const prevLink = document.querySelector('link[rel="prev"]');
|
||||
if (prevLink && prevLink.href) {
|
||||
window.location.href = prevLink.href;
|
||||
event.preventDefault();
|
||||
}
|
||||
break;
|
||||
case "ArrowRight":
|
||||
if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break;
|
||||
|
||||
const nextLink = document.querySelector('link[rel="next"]');
|
||||
if (nextLink && nextLink.href) {
|
||||
window.location.href = nextLink.href;
|
||||
event.preventDefault();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// some keyboard layouts may need Shift to get /
|
||||
switch (event.key) {
|
||||
case "/":
|
||||
if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break;
|
||||
Documentation.focusSearchBar();
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
// quick alias for translations
|
||||
const _ = Documentation.gettext;
|
||||
|
||||
_ready(Documentation.init);
|
||||
@@ -0,0 +1,13 @@
|
||||
const DOCUMENTATION_OPTIONS = {
|
||||
VERSION: '2.5.8',
|
||||
LANGUAGE: 'en',
|
||||
COLLAPSE_INDEX: false,
|
||||
BUILDER: 'html',
|
||||
FILE_SUFFIX: '.html',
|
||||
LINK_SUFFIX: '.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt',
|
||||
NAVIGATION_WITH_KEYS: false,
|
||||
SHOW_SEARCH_SUMMARY: true,
|
||||
ENABLE_SEARCH_SHORTCUTS: true,
|
||||
};
|
||||
|
After Width: | Height: | Size: 286 B |
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Sphinx stylesheet -- graphviz extension.
|
||||
*/
|
||||
|
||||
img.graphviz {
|
||||
border: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
object.graphviz {
|
||||
max-width: 100%;
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* This script contains the language-specific data used by searchtools.js,
|
||||
* namely the list of stopwords, stemmer, scorer and splitter.
|
||||
*/
|
||||
|
||||
var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"];
|
||||
|
||||
|
||||
/* Non-minified version is copied as a separate JS file, if available */
|
||||
|
||||
/**
|
||||
* Porter Stemmer
|
||||
*/
|
||||
var Stemmer = function() {
|
||||
|
||||
var step2list = {
|
||||
ational: 'ate',
|
||||
tional: 'tion',
|
||||
enci: 'ence',
|
||||
anci: 'ance',
|
||||
izer: 'ize',
|
||||
bli: 'ble',
|
||||
alli: 'al',
|
||||
entli: 'ent',
|
||||
eli: 'e',
|
||||
ousli: 'ous',
|
||||
ization: 'ize',
|
||||
ation: 'ate',
|
||||
ator: 'ate',
|
||||
alism: 'al',
|
||||
iveness: 'ive',
|
||||
fulness: 'ful',
|
||||
ousness: 'ous',
|
||||
aliti: 'al',
|
||||
iviti: 'ive',
|
||||
biliti: 'ble',
|
||||
logi: 'log'
|
||||
};
|
||||
|
||||
var step3list = {
|
||||
icate: 'ic',
|
||||
ative: '',
|
||||
alize: 'al',
|
||||
iciti: 'ic',
|
||||
ical: 'ic',
|
||||
ful: '',
|
||||
ness: ''
|
||||
};
|
||||
|
||||
var c = "[^aeiou]"; // consonant
|
||||
var v = "[aeiouy]"; // vowel
|
||||
var C = c + "[^aeiouy]*"; // consonant sequence
|
||||
var V = v + "[aeiou]*"; // vowel sequence
|
||||
|
||||
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
|
||||
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
|
||||
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
|
||||
var s_v = "^(" + C + ")?" + v; // vowel in stem
|
||||
|
||||
this.stemWord = function (w) {
|
||||
var stem;
|
||||
var suffix;
|
||||
var firstch;
|
||||
var origword = w;
|
||||
|
||||
if (w.length < 3)
|
||||
return w;
|
||||
|
||||
var re;
|
||||
var re2;
|
||||
var re3;
|
||||
var re4;
|
||||
|
||||
firstch = w.substr(0,1);
|
||||
if (firstch == "y")
|
||||
w = firstch.toUpperCase() + w.substr(1);
|
||||
|
||||
// Step 1a
|
||||
re = /^(.+?)(ss|i)es$/;
|
||||
re2 = /^(.+?)([^s])s$/;
|
||||
|
||||
if (re.test(w))
|
||||
w = w.replace(re,"$1$2");
|
||||
else if (re2.test(w))
|
||||
w = w.replace(re2,"$1$2");
|
||||
|
||||
// Step 1b
|
||||
re = /^(.+?)eed$/;
|
||||
re2 = /^(.+?)(ed|ing)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(fp[1])) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
}
|
||||
else if (re2.test(w)) {
|
||||
var fp = re2.exec(w);
|
||||
stem = fp[1];
|
||||
re2 = new RegExp(s_v);
|
||||
if (re2.test(stem)) {
|
||||
w = stem;
|
||||
re2 = /(at|bl|iz)$/;
|
||||
re3 = new RegExp("([^aeiouylsz])\\1$");
|
||||
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
||||
if (re2.test(w))
|
||||
w = w + "e";
|
||||
else if (re3.test(w)) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
else if (re4.test(w))
|
||||
w = w + "e";
|
||||
}
|
||||
}
|
||||
|
||||
// Step 1c
|
||||
re = /^(.+?)y$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(s_v);
|
||||
if (re.test(stem))
|
||||
w = stem + "i";
|
||||
}
|
||||
|
||||
// Step 2
|
||||
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
suffix = fp[2];
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(stem))
|
||||
w = stem + step2list[suffix];
|
||||
}
|
||||
|
||||
// Step 3
|
||||
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
suffix = fp[2];
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(stem))
|
||||
w = stem + step3list[suffix];
|
||||
}
|
||||
|
||||
// Step 4
|
||||
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
|
||||
re2 = /^(.+?)(s|t)(ion)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(mgr1);
|
||||
if (re.test(stem))
|
||||
w = stem;
|
||||
}
|
||||
else if (re2.test(w)) {
|
||||
var fp = re2.exec(w);
|
||||
stem = fp[1] + fp[2];
|
||||
re2 = new RegExp(mgr1);
|
||||
if (re2.test(stem))
|
||||
w = stem;
|
||||
}
|
||||
|
||||
// Step 5
|
||||
re = /^(.+?)e$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(mgr1);
|
||||
re2 = new RegExp(meq1);
|
||||
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
||||
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
|
||||
w = stem;
|
||||
}
|
||||
re = /ll$/;
|
||||
re2 = new RegExp(mgr1);
|
||||
if (re.test(w) && re2.test(w)) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
|
||||
// and turn initial Y back to y
|
||||
if (firstch == "y")
|
||||
w = firstch.toLowerCase() + w.substr(1);
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg class="theme-icon" style="fill:#00ba10;" data-theme="light-theme" version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||
<path d="M16 9c-3.859 0-7 3.141-7 7s3.141 7 7 7 7-3.141 7-7c0-3.859-3.141-7-7-7zM16 7c0.552 0 1-0.447 1-1v-2c0-0.552-0.448-1-1-1-0.553 0-1 0.448-1 1v2c0 0.553 0.447 1 1 1zM16 25c-0.553 0-1 0.448-1 1v2c0 0.553 0.447 1 1 1 0.552 0 1-0.447 1-1v-2c0-0.552-0.448-1-1-1zM23.776 9.635l1.414-1.414c0.391-0.391 0.391-1.023 0-1.414s-1.023-0.391-1.414 0l-1.414 1.414c-0.391 0.391-0.391 1.023 0 1.414s1.023 0.391 1.414 0zM8.221 22.366l-1.414 1.414c-0.391 0.391-0.391 1.023 0 1.414s1.023 0.391 1.414 0l1.414-1.414c0.391-0.393 0.391-1.023 0-1.414s-1.023-0.393-1.414 0zM7 16c0-0.552-0.448-1-1-1h-2c-0.553 0-1 0.448-1 1 0 0.553 0.447 1 1 1h2c0.552 0 1-0.447 1-1zM28 15h-2c-0.553 0-1 0.448-1 1 0 0.553 0.447 1 1 1h2c0.552 0 1-0.447 1-1 0-0.552-0.448-1-1-1zM8.22 9.635c0.391 0.391 1.023 0.391 1.414 0s0.391-1.023 0-1.414l-1.414-1.414c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.023 0 1.414l1.414 1.414zM23.779 22.363c-0.393-0.391-1.023-0.391-1.414 0s-0.393 1.023 0 1.414l1.414 1.414c0.391 0.391 1.023 0.391 1.414 0s0.391-1.023 0-1.414l-1.414-1.414z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 90 B |
|
After Width: | Height: | Size: 90 B |
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,289 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 1560 800" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g id="snake-body">
|
||||
<g id="snake_body_base" transform="matrix(1,0,0,1,-3,-3.04251)">
|
||||
<path d="M362.273,570.841C363.044,572.445 394.789,607.529 368.474,662.66C338.751,724.933 249.576,750.513 191.081,659.956C52.719,445.753 234.75,39.212 663.971,103.294C904.645,139.226 1046.89,311.203 1104.44,367.865C1137.92,400.827 1191.31,422.791 1199.59,421.555C1202.35,418.601 1214.29,417.702 1209.34,348.257C1202,245.212 1178.86,221.316 1179.63,214.281C1196.69,58.183 1406.72,12.137 1500.57,141.687C1541.08,197.606 1551.89,255.843 1547.17,262.701C1470.86,373.47 1438.1,446.717 1410.36,488.093C1393.32,513.502 1324.9,621.61 1207.75,623.767C1170.29,624.456 1076.69,611.426 973.642,511.843C861.734,403.696 781.514,292.361 567.047,289.841C456.894,288.546 357.369,371.25 342.061,476.745C335.049,525.068 342.686,543.859 362.273,570.841Z" style="fill:rgb(240,204,0);stroke:black;stroke-width:5px;"/>
|
||||
</g>
|
||||
<g id="snake_body_light" transform="matrix(1,0,0,1,-3,-3.04251)">
|
||||
<path d="M1244.8,224.652C1247.22,217.185 1248.51,209.384 1250.92,201.917C1252.1,198.263 1253.85,194.808 1255.56,191.374C1256.38,189.75 1260.63,181.248 1267.67,172.182C1268.77,170.762 1274.56,163.308 1283.08,155.846C1291.54,148.438 1299.7,143.665 1301.25,142.761C1311.02,137.042 1319.92,133.917 1321.62,133.322C1332.44,129.522 1341.85,128.182 1343.65,127.926C1355.24,126.275 1364.94,126.856 1366.79,126.967C1366.8,126.968 1378.6,128.274 1378.61,128.276C1382.48,129.11 1386.4,129.75 1390.23,130.778C1392.02,131.259 1401.41,133.782 1411.88,139.019C1413.51,139.831 1422.01,144.084 1431.08,151.118C1432.49,152.219 1439.95,158.003 1447.41,166.524C1448.59,167.872 1454.82,174.984 1460.5,184.69C1466.21,194.468 1469.34,203.371 1469.93,205.066C1473.73,215.894 1475.07,225.306 1475.33,227.103C1476.98,238.697 1476.4,248.403 1476.29,250.253C1475.81,258.158 1475.65,258.143 1474.34,265.951C1473.89,268.59 1473.36,271.628 1473.36,271.638C1473.36,271.64 1471.66,276.172 1469.61,281.375C1449.23,333.263 1429.07,367.991 1425.86,374.095C1387.36,447.314 1351.12,483.081 1332.25,499.531C1329.6,501.835 1308.85,525.959 1275.27,542.976C1230.56,565.636 1191.77,561.649 1173.9,558.939C1119.15,550.636 1074.05,517.054 1042.49,487.586C1037.11,482.567 1035.77,482.292 1007.07,454.141C977.474,425.111 934.267,381.647 890.652,347.953C844.517,312.312 808.127,293.176 769.435,278.008C769.309,277.958 758.03,273.346 738.637,267.296C718.805,261.111 705.202,258.047 702.841,257.343C687.667,252.818 663.972,246.414 635.871,241.733C635.076,241.6 616.204,238.997 593.837,238.329C559.826,237.311 533.915,241.349 525.858,242.669C525.798,242.679 518.716,243.914 509.741,246.079C465.257,256.813 440.179,274.192 433.795,278.029C403.01,296.531 384.967,317.909 374.719,331.371C360.148,350.511 349.211,371.826 341.88,393.941C341.274,395.769 340.296,397.569 337.833,404.075C324.786,438.535 323.708,467.047 323.681,480.805C323.608,518.538 334.816,540.264 337.51,545.512L337.463,545.445C339.755,552.464 344.062,558.715 346.354,565.734C347.473,569.16 347.525,572.871 347.595,576.474C347.665,580.054 347.385,583.657 346.773,587.185C346.162,590.713 345.215,594.199 343.945,597.547C342.666,600.915 341.068,604.182 339.164,607.241C337.23,610.345 334.996,613.286 332.486,615.947C332.475,615.959 323.967,623.347 323.96,623.351C320.686,625.194 317.579,627.368 314.139,628.876C310.791,630.344 307.27,631.458 303.697,632.234C300.177,632.998 296.564,633.404 292.962,633.474C289.383,633.544 285.781,633.263 282.253,632.652C278.725,632.041 275.238,631.093 271.889,629.823C268.519,628.545 265.251,626.947 262.191,625.043C259.084,623.11 256.14,620.877 253.477,618.367C249.684,614.795 243.246,606.252 242.417,605.151C206.274,557.191 197.398,501.461 194.982,485.016C192.92,470.977 192.275,456.77 192.163,454.305C189.966,405.89 198.605,367.575 202.845,350.649C202.846,350.645 204.633,344.798 207.243,337.427C230.56,271.59 266.123,231.074 278.125,217.858C300.015,193.756 326.645,171.193 358.532,152.178C358.885,151.968 373.122,143.553 393.541,134.712C445.507,112.212 490.833,106.71 509.281,104.361C574.055,96.115 628.197,103.18 653.746,107.048C657.647,107.639 692.084,111.147 739.466,123.107C741.412,123.598 757.81,128.477 777.168,135.427C779.791,136.368 794.351,141.482 818.662,151.762C884.839,179.746 935.477,213.386 994.615,264.781C1052.35,314.953 1098.82,367.499 1125.54,391.876C1125.59,391.918 1135.43,400.282 1147.38,408.116C1174.04,425.593 1188.68,426.027 1192.48,426.113L1192.48,426.104C1196.88,426.01 1204.88,425.234 1216.79,412.397C1219.79,409.168 1222.15,406.098 1223.42,404.401C1223.57,404.207 1223.6,404.219 1224.49,402.109C1230.57,387.819 1240.22,359.725 1244.91,312.152C1244.92,312.079 1245.94,297.534 1245.84,277.626C1245.69,250.845 1243.64,231.542 1243.67,231.335C1243.75,230.795 1243.78,230.798 1244.8,224.652Z" style="fill:rgb(254,227,45);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Pygame-ce">
|
||||
<g id="Pygame_shadow" transform="matrix(1,0,0,1,-3,-3.04251)">
|
||||
<path d="M172.358,365.396C194.988,303.834 232.047,248.148 285.506,201.766C285.506,201.766 285.706,206.452 287.015,215.748C288.74,227.988 279.732,251.654 279.971,252.37C280.806,254.517 281.531,257.794 291.557,260.269C299.647,262.266 296.192,258.581 295.423,248.977C294.765,240.758 295.945,237.51 298.627,233.644C303.136,227.145 307.776,226.123 317.709,217.11C327,208.679 328.931,202.623 349.185,192.361C354.685,189.575 370.052,183.78 378.073,187.321C387.807,191.617 390.654,195.647 395.498,200.941C400.668,206.592 408.054,222.217 409.095,221.225C417.448,213.264 423.483,201.804 434.331,197.736C444.709,193.919 478.468,195.35 502.684,200.599C507.428,201.627 510.084,200.896 510.084,200.896C510.084,200.896 511.949,196.132 514.493,194.157C520.891,189.19 541.572,189.982 550.518,192.01C556.722,193.561 562.997,200.917 565.072,207.756C568.193,218.047 573.303,244.02 573.303,244.02C573.303,244.02 585.469,228.731 592.031,224.337C617.981,206.963 648.641,198.428 679.135,193.468C694.876,190.907 722.066,189.446 740.188,215.748C754.487,236.502 756.354,246.464 758.282,248.393C758.844,248.955 769.685,238.673 774.663,231.853C780.526,223.818 793.451,212.905 803.053,208.353C811.931,204.144 824.883,203.7 832.279,204.535C838.092,205.158 844.972,207.638 850.003,210.561C856.541,214.36 863.08,222.612 863.941,224.337C864.674,225.803 867.654,214.409 872.721,207.756C877.658,201.273 886.997,198.73 893.615,197.157C897.372,196.265 898.279,196.625 902.375,196.067C997.086,255.91 1067.82,335.452 1102.6,369.702C1121.87,388.672 1147.73,404 1167.8,413.358C1167.8,413.358 1161.57,426.799 1159.73,428.772C1140.89,448.921 1127.63,454.101 1099.01,457.586C1082.07,459.648 1062.39,455.927 1048.58,452.74C1036.66,449.989 1023.24,438.938 1014.17,430.724C997.877,415.965 989.609,389.684 989.223,386.867C982.719,418.053 944.2,460.741 909.442,434.131C893.695,422.075 889.254,396.068 887.737,384.53C886.818,377.545 890.039,359.098 887.379,357.69C884.736,356.248 882.787,359.918 881.695,361.415C877.765,366.802 876.968,369.163 871.275,372.959C868.482,374.774 864.514,378.933 852.282,391.165C782.523,331.754 701.341,288.657 567.047,287.078C468.722,285.923 376.308,353.441 347.258,442.609C347.258,442.609 338.464,453.382 319.923,457.072C290.043,463.018 261.319,461.67 232.394,452.74C199.94,442.721 168.924,406.392 183.222,371.123C185.547,365.386 193.751,355.951 198.53,350.739C194.616,354.89 182.903,361.212 172.358,365.396Z" style="fill-opacity:0.15;"/>
|
||||
</g>
|
||||
<g id="Pygame" transform="matrix(1.19289,0,0,1.19289,-10.1906,36.483)">
|
||||
<g id="shadow_outline" transform="matrix(0.744353,0,0,0.744353,-1.87816,0.159385)">
|
||||
<path d="M446.083,428.557C430.438,439.977 404.513,447.031 385.555,450.803C351.903,457.5 316.842,453.812 284.266,443.755C247.716,432.472 212.785,391.558 228.887,351.837C231.507,345.376 240.746,334.75 246.128,328.88C248.565,326.295 250.1,324.653 250.1,324.653C250.1,324.653 248.483,326.311 246.128,328.88C239.045,336.391 224.342,351.853 217.49,358.1C200.114,373.944 175.999,378.478 153.392,380.25L154.064,396.64C154.263,401.47 154.678,406.366 153.922,411.14C152.136,422.427 138.526,425.078 131.625,431.528C128.573,434.38 127.439,438.839 124.611,441.915C113.624,453.865 96.498,456.522 81.115,456.424C66.874,456.289 59.754,455.618 51.962,453.603C46.401,452.136 40.315,450.122 36.147,445.824C31.991,441.538 29.818,435.015 28.452,429.42C24.337,412.566 21.857,399.252 19.988,381.997C19.182,374.608 17.839,363.726 17.167,357.815C15.017,341.29 13.405,286.612 14.211,259.743C14.639,244.553 14.578,230.507 18.976,215.615C22.267,204.471 33.585,192.606 44.445,184.989C54.989,170.03 76.974,156.546 93.867,151.741C107.756,147.79 126.516,146.3 140.745,145.801C163.456,145.004 184.623,147.945 208.52,153.207C227.058,157.289 239.278,165.107 255.091,175.509C271.818,157.713 299.746,139.337 326.196,151.9C332.107,154.721 344.306,166.382 345.781,176.852C347.723,190.637 337.579,217.29 337.848,218.096C338.788,220.514 339.605,224.204 350.897,226.992C360.008,229.241 356.116,225.091 355.25,214.275C354.509,205.018 355.838,201.36 358.859,197.006C363.937,189.687 369.162,188.536 380.349,178.386C390.813,168.891 392.987,162.07 415.798,150.513C421.992,147.375 439.298,140.849 448.332,144.837C459.294,149.676 462.5,154.214 467.956,160.176C473.779,166.54 482.097,184.137 483.269,183.019C492.676,174.054 499.472,161.148 511.69,156.566C523.378,152.267 561.397,153.879 588.669,159.791C594.013,160.949 597.004,160.125 597.004,160.125C597.004,160.125 599.104,154.76 601.97,152.536C609.175,146.942 632.466,147.834 642.542,150.118C649.528,151.864 656.595,160.148 658.932,167.851C662.447,179.441 668.202,208.692 668.202,208.692C668.202,208.692 681.904,191.473 689.294,186.525C718.519,166.958 753.049,157.345 787.391,151.759C805.119,148.876 835.741,147.23 856.15,176.852C872.254,200.226 874.356,211.445 876.528,213.617C877.161,214.25 889.37,202.67 894.976,194.989C901.579,185.94 916.135,173.65 926.95,168.523C936.947,163.783 951.535,163.283 959.864,164.224C966.411,164.925 974.159,167.718 979.824,171.01C987.188,175.289 994.552,184.583 995.522,186.525C996.347,188.176 999.704,175.344 1005.41,167.851C1010.97,160.55 1023.74,154.307 1031.19,152.536C1066.29,144.197 1100.45,151.412 1123.02,183.019C1127.25,188.93 1138.89,208.692 1138.89,208.692C1138.89,208.692 1165.01,183.286 1175.53,174.05C1182.12,168.269 1200.67,158.118 1209.12,155.481C1268.43,136.969 1328.89,170.649 1358.63,222.959C1370.14,243.212 1371.18,267.401 1373.26,289.896C1373.97,297.61 1374.55,299.828 1368.76,305.69C1367.38,307.088 1359.91,309.888 1360.87,310.456C1362.22,311.256 1370.29,313.789 1372.51,316.185C1377.62,321.709 1375.37,337.912 1373.56,344.025C1366.05,369.409 1355.27,388.28 1328.64,416.762C1307.42,439.455 1292.49,445.288 1260.26,449.212C1241.18,451.534 1219.01,447.344 1203.47,443.755C1190.04,440.656 1174.92,428.211 1164.71,418.961C1146.36,402.339 1137.05,372.74 1136.62,369.568C1129.29,404.691 1085.91,452.766 1046.77,422.797C1029.03,409.22 1024.03,379.93 1022.32,366.936C1021.29,359.069 1024.91,338.294 1021.92,336.708C1018.94,335.085 1016.75,339.218 1015.52,340.904C1011.09,346.971 1010.19,349.63 1003.78,353.904C1000.12,356.287 1000.9,361.504 1000.69,365.055C1000.47,368.947 996.583,401.33 985.553,416.749C974.076,432.791 936.316,443.153 923.877,438.818C889.7,426.905 879.115,368.234 879.115,368.234C879.115,368.234 874.338,434.496 798.198,445.824C764.23,450.878 712.126,438.156 694.685,428.557C665.478,412.483 663.363,401.821 662.147,393.564C654.259,424.764 640.579,432.86 618.601,442.074C605.841,447.424 568.19,452.324 549.306,452.324C533.997,452.324 519.758,448.365 505.299,439.184C487.91,428.143 478.602,413.658 479.421,382.28C473.465,406.749 461.727,417.136 446.083,428.557ZM565.562,352.038C565.013,351.022 564.605,349.934 564.21,348.849C563.195,346.059 567.178,345.026 569.113,344.883C570.21,344.802 571.318,344.903 572.414,344.8C573.587,344.69 577.111,343.85 577.727,343.941C578.689,344.083 578.957,345.295 578.965,346.065C578.979,347.483 578.663,349.497 578.033,350.788C576.903,353.106 574.15,353.645 571.876,354.053C567.846,354.59 566.771,354.322 565.562,352.038ZM1245.62,341.29C1244.21,340.763 1239.45,338.913 1240.01,337.967C1240.65,336.892 1246.99,337.11 1248.94,337.059C1252.79,336.96 1260.71,336.771 1261.74,337.797C1262.32,338.381 1260.78,340.517 1260.26,341.156C1257.71,344.112 1253.41,344.246 1245.62,341.29ZM157.557,266.729C157.557,259.474 155.408,256.787 146.541,253.294C144.916,252.633 143.25,252.058 141.549,251.628C140.272,251.305 138.957,251.095 137.64,251.044C136.883,251.015 136.099,251.114 135.394,251.392C133.347,252.199 134.549,255.025 134.991,256.279C136.528,260.637 138.949,264.79 142.51,267.804C146.809,2Line truncated
|
||||
</g>
|
||||
<g id="e">
|
||||
<path id="e_mid" d="M915.4,310C890.7,304.2 871.7,292.5 859.5,275.5C854.2,268 848.143,255.637 847.1,252.2C843.25,239.518 846.7,190.7 848,184.3C854.2,154.4 873.2,132.4 901.4,122.7C909.7,119.9 911.6,119.6 922.5,119.6C946.9,119.7 965,127.7 984.3,147.2C991.9,154.8 994.8,158.6 997.2,163.8C998.9,167.5 1001.3,172.1 1002.5,174C1005.8,179.4 1009,194 1009.7,207C1010.2,217 1010.1,218.8 1008.6,220.2C1004.6,224.3 989.2,226 957,226C935.5,226.1 902.8,224.6 901.1,223.6C900.7,223.3 899.4,223.7 898.4,224.5C896.8,225.6 896.5,227 896.6,232.7C896.8,240.8 898.2,243.9 904.2,249.6C910,255.1 914,257.4 923.4,260.4C933.6,263.8 938.6,263.8 943.5,260.4C948.3,257.2 950.1,254.9 954,247.9C957.6,241.1 959.3,240.3 971.5,239.6C976.5,239.2 984.7,238.5 989.8,237.9C1001.6,236.4 1009.8,237.1 1011.6,239.5C1015.6,245 1007.61,267.208 999.6,278C990.85,289.783 973.133,304.867 959.1,310.2C945.483,315.375 926.7,312.6 915.4,310ZM953.301,188.795C960.3,185.245 960.401,182.995 954.301,177.295C951.701,174.995 946.501,171.395 942.701,169.395C933.201,164.395 926.301,164.295 918.001,168.995C908.701,174.195 903.101,181.095 905.501,184.395C907.401,186.995 913.201,190.095 917.601,190.895C920.201,191.395 928.201,191.695 935.301,191.495C946.801,191.295 948.901,190.995 953.301,188.795Z" style="fill:rgb(199,198,149);fill-rule:nonzero;"/>
|
||||
<path id="e_bottom" d="M915.4,310C890.7,304.2 871.7,292.5 859.5,275.5C854.2,268 848.643,256.913 847.099,252.006C846.316,249.515 845.963,246.467 845.849,244.662C845.849,244.662 850.035,243.131 852.171,241.133C854.492,238.961 857.52,234.318 859.421,233.824C863.646,232.725 867.463,245.149 868.323,245.671C869.184,246.193 878.128,246.496 879.014,245.471C883.406,240.386 890.428,236.145 893.431,240.239C895.241,242.707 897.537,247.018 900.157,248.101C901.106,248.493 902.327,248.032 902.327,248.032C902.327,248.032 904.74,250.108 904.913,250.268C910.341,255.292 914.39,257.524 923.4,260.4C933.6,263.8 938.6,263.8 943.5,260.4C947.145,257.97 949.06,256.059 951.478,252.215C952.245,250.997 957.62,253.098 965.253,249.516C976.375,244.298 977.437,240.052 981.251,242.813C985.726,246.054 987.611,245.008 993.844,245.324C1004.38,245.859 1005.31,237.213 1008.93,238.352C1010.13,238.732 1011.15,238.9 1011.6,239.5C1015.6,245 1007.61,267.208 999.6,278C990.85,289.783 973.133,304.867 959.1,310.2C945.483,315.375 926.7,312.6 915.4,310Z" style="fill:rgb(255,254,191);fill-rule:nonzero;"/>
|
||||
<path id="e_top" d="M1006.3,184.38C1006.56,185.396 1000.28,179.352 993.999,180.776C981.283,183.657 983.188,189.019 978.097,189.873C971.966,190.902 967.482,179.035 966.858,181.812C965.881,186.162 963.835,190.772 957.481,186.227C957.127,185.974 959.509,185.207 958.376,182.235C956.295,176.779 938.186,164.162 927.852,165.608C916.427,167.206 903.439,178.535 905.164,183.785C905.926,186.105 905.637,190.321 900.038,190.094C890.009,189.825 889.385,179.676 882.167,180.827C875.385,181.909 871.592,192.172 867.226,195.781C864.545,197.998 862.159,187.096 854.763,187.009C851.701,186.973 850.448,189.405 849.092,190.668C848.337,191.371 847.4,191.225 847.423,190.806C847.599,187.628 847.793,185.319 848,184.3C854.2,154.4 873.2,132.4 901.4,122.7C909.7,119.9 911.6,119.6 922.5,119.6C946.9,119.7 965,127.7 984.3,147.2C991.9,154.8 994.8,158.6 997.2,163.8C998.9,167.5 1001.3,172.1 1002.5,174C1003.84,176.188 1005.16,179.888 1006.3,184.38Z" style="fill:rgb(148,147,111);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="m">
|
||||
<path id="m_mid" d="M846,189.4C847.264,199.322 847.132,207.189 846.485,223.235C845.823,239.664 843.607,254.573 843,256.9C839.9,269.1 836.1,276.7 830.4,282.3C822.8,289.6 816.5,291.9 807.4,290.5C803.4,289.9 801.9,288.9 796.1,283.2C787.9,275 784.4,268.1 783.6,258.5C782.9,251.3 783.7,244.8 788.4,220.7C789.7,213.6 791.2,203.5 791.5,198.1C792.2,188.9 792.1,188.1 789.6,183.2C785.1,174.3 780.1,174.3 778.5,183.3C776.4,195 768,227 765.9,231.5C761.1,241.7 753.7,244.1 746.1,238.1C742.3,235.1 734.2,223.5 722.7,205C720.2,200.8 716.4,195.5 714.4,193.1C711.1,189.3 710.6,189 709.2,190.4C707.2,192.4 705.325,202.128 708,210.6C709.2,214.4 720.1,235 722.5,238C723.8,239.6 728.2,248.1 732.1,256.5C736.5,265.9 735.5,282.2 729.9,293.3C726.9,299.2 720.3,305.8 715.1,308.1C709.1,310.8 696.3,311.2 690.7,308.7C685.6,306.5 676.2,296.8 672.4,290C664.1,275.2 657.7,253 655.9,233C652.6,197.5 661.7,158.7 676.7,143.6C685,135.3 697,130 707.8,130C713.8,130 715.3,130.4 720.9,133.8C724.4,135.8 729.1,139.7 731.4,142.4C737.5,149.7 738.575,152 741,152C743.425,152 744.906,146.517 747.035,140.264C748.982,134.546 748.673,131.427 753,127.1C761.5,118.6 788.3,115.5 803,121.2C817.6,126.9 831.9,143.9 838.9,163.7C841.5,171 844.877,180.584 846,189.4Z" style="fill:rgb(195,146,146);fill-rule:nonzero;"/>
|
||||
<path id="m_bottom2" d="M784.747,240.624C784.97,239.227 789.015,246.383 795.137,249.278C796.446,249.897 803.677,239.162 813.561,239.128C817.19,239.116 819.823,239.677 826.503,249.191C827.796,251.032 832.249,251.375 838.213,249.248C843.048,247.524 844.847,244.272 844.794,244.734C844.057,251.133 843.314,255.697 843,256.9C839.9,269.1 836.1,276.7 830.4,282.3C822.8,289.6 816.5,291.9 807.4,290.5C803.4,289.9 801.9,288.9 796.1,283.2C787.9,275 784.4,268.1 783.6,258.5C783.15,253.872 783.32,249.533 784.747,240.624Z" style="fill:rgb(255,191,191);fill-rule:nonzero;"/>
|
||||
<path id="m_bottom1" d="M672.4,290C666.334,279.184 658.271,249.256 658.271,249.256C662.429,251.073 664.693,251.869 667.029,250.052C669.744,247.94 671.843,239.75 675.661,241.393C678.732,242.716 682.602,250.331 685.225,251.574C689.194,253.455 692.039,244.353 695.927,244.091C704.321,243.523 709.548,245.795 712.551,240.915C714.756,237.332 719.169,239.268 719.746,239.748C722.402,241.958 722.921,249.45 726.902,250.295C728.356,250.603 728.653,249.306 728.653,249.306C728.653,249.306 730.964,254.053 732.1,256.5C736.5,265.9 735.5,282.2 729.9,293.3C726.9,299.2 720.3,305.8 715.1,308.1C709.1,310.8 696.3,311.2 690.7,308.7C685.6,306.5 676.2,296.8 672.4,290Z" style="fill:rgb(255,191,191);fill-rule:nonzero;"/>
|
||||
<path id="m_top" d="M844.298,180.688C844.359,180.966 841.662,182.5 840.768,183.543C837.468,187.395 839.789,194.766 836.494,196.652C833.606,198.305 831.293,196.178 830.836,195.771C826.592,191.993 822.374,181.476 813.086,182.034C805.358,182.498 800.722,191.352 795.553,190.302C792.373,189.656 790.05,184.081 789.6,183.2C787.042,178.142 784.793,176.364 782.536,176.673C781.816,176.772 780.123,177.75 779.092,180.869C778.99,181.437 777.228,179.526 776.236,180.688C772.776,184.74 771.742,182.295 771.115,183.105C768.828,186.058 766.691,186.108 764.352,185.654C761.643,185.128 759.828,180.544 759.828,180.544C759.331,185.186 759.057,192.943 752.243,187.914C748.327,185.023 745.465,181.004 740.929,180.841C734.103,180.597 726.77,184.734 726.659,187.963C726.4,195.484 723.064,195.512 722.43,195.489C718.648,195.354 714.293,189.111 712.821,187.219C711.032,184.92 702.674,177.92 699.949,179.305C690.386,184.166 697.318,189.758 692.972,195.58C691.83,197.109 688.043,197.584 685.191,195.83C680.903,193.193 677.354,187.35 677.112,187.093C674.504,184.33 672.556,184.316 670.228,183.052C668.574,182.154 666.941,180.418 666.46,178.651C666.083,177.265 659.974,178.43 659.974,178.43C659.974,178.43 663.822,165.252 666.314,159.702C669.302,153.05 672.802,147.524 676.7,143.6C685,135.3 697,130 707.8,130C713.8,130 715.3,130.4 720.9,133.8C724.4,135.8 729.1,139.7 731.4,142.4C737.5,149.7 738.527,152 741,152C743.473,152 744.902,146.528 747.091,140.104C749.033,134.405 748.787,131.313 753,127.1C761.5,118.6 788.3,115.5 803,121.2C817.6,126.9 831.9,143.9 838.9,163.7C841.5,171 842.201,171.134 844.298,180.688Z" style="fill:rgb(149,112,112);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="a">
|
||||
<path id="a_mid" d="M572,312.9C562.5,311.9 549,308.8 541.5,305.8C512.8,294.6 497.2,279.9 494,260.9C491.4,245.8 495.4,234 508.9,216.1C512.8,211 524,202.5 532.2,198.5C538.5,195.4 540.8,194.8 549.2,194.3C558.5,193.8 559.3,193.9 567.2,196.9C571.8,198.7 578,201.5 581.2,203.1C584.3,204.7 588.8,206.3 591.2,206.6C595.2,207.2 595.8,206.9 600,203.2C604.3,199.4 604.5,199 604.4,193.8C604.3,190.8 603.5,186.8 602.6,184.9C600.5,180.5 592,171 587.1,167.6C583.4,165 582.9,164.9 577.4,165.9C574.2,166.5 569.8,167.9 567.6,169.1C562.9,171.5 556.683,177 553,180C550.331,182.174 549.6,183.6 545.5,187.1C539.2,192.5 537,193.7 532.2,194.7C526.4,195.8 518,195.1 514.2,193.1C507.6,189.5 503.7,179.8 503.6,166.5C503.5,161.3 503.9,159.9 506.8,155.7C512.1,148.1 517.8,143.5 528.5,138.1C539,132.8 554.474,127.387 561.5,125.6C564.109,124.936 570.804,123.32 575.5,122.5C598.337,118.514 611.4,121 618.9,127.1C621.2,129 624.9,132.9 627.1,135.8C631.9,142.1 637.536,150.262 641,158.4C644.817,167.367 647.7,177.8 650,189.6C651.9,199.5 652.1,203.5 651.7,224.1C651.3,249.4 650.8,253.2 645,270.1C640,284.4 636.4,290.7 628.6,298.6C617.5,309.7 610.1,312.7 592,313.4C585.7,313.7 576.7,313.5 572,312.9ZM567.755,268.525C575.51,271.324 583.351,271.527 587.899,269.579C589.479,268.902 591.164,266.937 592.223,262.913C592.426,262.143 592.324,261.514 592.304,261.321C591.937,257.712 589.139,253.47 583.808,248.755C573.008,239.055 564.01,238.19 556.01,245.59C552.448,248.878 551.036,251.637 551.243,254.279C551.338,255.493 551.882,256.923 552.534,258.094C555.464,263.356 560.298,265.833 567.755,268.525Z" style="fill:rgb(149,150,199);fill-rule:nonzero;"/>
|
||||
<path id="a_bottom" d="M572,312.9C562.5,311.9 549,308.8 541.5,305.8C512.8,294.6 497.2,279.9 494,260.9C493.141,255.911 493.689,246.675 493.689,246.675C493.689,246.675 495.325,248.94 501.408,241.381C507.478,233.836 511.537,250.643 518.47,250.784C521.065,250.837 527.583,251.483 537.818,240.495C542.151,235.843 548.148,237.689 547.719,242.085C546.95,249.973 551.183,254.274 551.183,254.274C551.183,254.274 552.168,259.697 556.275,262.709C562.736,267.447 574.753,272.527 586.355,270.15C590.226,269.358 591.729,265.248 592.219,262.694C592.99,258.683 588.269,253.301 588.269,253.301C588.269,253.301 592.037,254.075 595.453,252.172C600.519,249.35 606.347,238.613 613.392,231.394C619.074,225.574 626.73,233.703 624.93,241.849C624.609,243.299 628.333,247.824 629.436,248.001C630.592,248.186 635.198,242.505 640.86,241.09C646.792,239.608 651.128,242.736 651.084,243.37C650.393,253.336 648.886,258.778 645,270.1C640,284.4 636.4,290.7 628.6,298.6C617.5,309.7 610.1,312.7 592,313.4C585.7,313.7 576.7,313.5 572,312.9Z" style="fill:rgb(191,192,255);fill-rule:nonzero;"/>
|
||||
<path id="a_top" d="M637.883,182.841C634.645,185.825 631.737,194.187 627.82,195.049C626.517,195.336 624.555,191.126 624.14,190.372C621.597,185.752 619.167,178.445 610.353,179.547C606.464,180.033 606.531,183.603 605.469,184.566C603.802,186.08 602.681,185.07 602.6,184.9C600.5,180.5 592,171 587.1,167.6C583.4,165 582.9,164.9 577.4,165.9C574.2,166.5 569.8,167.9 567.6,169.1C562.9,171.5 553,180 553,180C553,180 550.082,178.457 544.517,182.659C541.055,185.274 540.297,183.433 538.473,184.352C537.187,185 536.27,187.865 533.861,188.367C532.748,188.578 531.188,185.674 528.794,185.518C525.876,185.329 525.618,189.352 520.037,188.501C517.69,188.143 518.08,186.225 516.053,185.355C514.322,184.612 512.432,184.995 512.353,184.722C511.192,180.698 507.871,180.143 506.508,180.332C506.226,180.371 505.231,179.721 505.143,179.383C504.168,175.637 503.636,171.303 503.6,166.5C503.5,161.3 503.9,159.9 506.8,155.7C512.1,148.1 517.8,143.5 528.5,138.1C539,132.8 554.807,127.289 561.5,125.6C563.668,125.053 572.782,122.993 575.5,122.5C598.309,118.36 611.4,121 618.9,127.1C621.2,129 624.9,132.9 627.1,135.8C634.648,145.749 637.642,151.509 641,158.4C643.885,164.321 647.246,177.147 647.246,177.147C647.246,177.147 640.676,180.268 637.883,182.841Z" style="fill:rgb(104,105,139);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="g">
|
||||
<path id="g_mid" d="M362.735,219.125C362.435,219.125 360.2,185.6 360.2,185.6L359.8,174.1C359.2,159.7 360.2,152.2 363.6,147.3C365,145.2 367.3,141.3 368.7,138.5C371.8,132.3 376.3,127.5 381.5,124.7C387.7,121.4 405.8,121.7 425.5,125.5C433.8,127.1 442.5,128.4 445,128.4C449.2,128.5 449.5,128.3 449.5,125.8C449.5,121.8 452,120 459.1,119C466.5,117.9 474.8,119.3 477.9,122.1C480.9,125 485.7,142.9 488.4,162C495.4,211.7 492.6,270.8 482.4,291.2C477.5,300.8 463.1,309.2 447,311.7C433.2,313.8 406.2,313 396,310C382,306 373,298.9 367.5,287.6C362.8,277.8 361.3,267.8 362.8,256.5C364.3,244.8 366.1,241.3 371.4,239.9C377.3,238.2 384.8,237.8 390,238.9C392.5,239.5 396.6,240.2 399.2,240.5C402.8,241 404.9,242 407.6,244.6C411.2,248 411.3,248.1 410.7,254.1C409.9,260.8 411.3,265.3 415.1,268.9C417.9,271.5 422.9,271.6 430.8,269.4C442,266.2 448,261.9 451.2,254.9C453.7,249.2 455.4,234.6 454.5,226.3L453.7,219.5L452.5,222.9C451.1,227.1 447.7,229.8 442.4,231C434.9,232.7 408.3,234.2 392,233.8C371.8,233.4 369.2,232.5 365.2,224.3C363.8,221.4 363.135,219.125 362.735,219.125ZM432.9,194.5C444.8,188.4 446.3,164.7 435.4,156.1C430.1,151.9 412.4,153.9 408,159.2C405.3,162.5 403.1,169.4 402.4,177C401.4,187.4 405,192.8 415,196.1C418.6,197.3 429.4,196.4 432.9,194.5Z" style="fill:rgb(151,199,149);fill-rule:nonzero;"/>
|
||||
<g id="g_bottom" transform="matrix(0.744353,0,0,0.744353,-1.87816,0.159385)">
|
||||
<path d="M609.747,341.481C610.964,339.109 612.162,338.335 614.329,338.335C616.882,338.335 619.972,335.648 627.226,327.05C632.466,320.87 637.705,315.362 638.78,314.959C643.885,312.944 645.9,314.153 647.512,319.929C649.796,328.662 653.692,334.304 657.588,334.304C657.94,334.304 658.254,334.312 658.534,334.337C661.058,332.218 662.512,332.31 662.068,337.295C659.974,360.757 656.083,380.036 650.602,390.998C644.02,403.895 624.674,415.18 603.044,418.539C595.549,419.679 585.155,420.183 574.525,420.112C573.01,420.17 571.74,420.186 570.802,420.151C570.26,420.122 569.506,420.075 568.595,420.013C554.913,419.65 541.662,418.353 534.529,416.255C515.72,410.881 503.629,401.342 496.24,386.161C489.926,372.996 487.911,359.561 489.926,344.38C490.165,342.517 490.409,340.809 490.667,339.241C490.838,338.201 494.815,338.215 495.63,337.7C497.22,336.696 500.045,334.743 502.42,332.558C512.227,323.288 516.526,320.601 521.228,321.139C525.662,321.542 527.14,323.154 528.349,329.199C529.289,333.633 534.663,335.648 545.948,335.648L554.648,335.784C554.648,335.784 554.637,336.793 554.562,337.938C554.479,339.198 554.33,340.628 554.277,341.156C553.202,350.157 555.083,356.203 560.188,361.039C563.95,364.532 570.667,364.666 581.281,361.711C596.327,357.412 604.388,351.635 608.687,342.231C608.909,341.723 609.267,341.493 609.747,341.481Z" style="fill:rgb(194,255,191);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="g_top" transform="matrix(0.744353,0,0,0.744353,-1.87816,0.159385)">
|
||||
<path d="M597.026,239.487C597.026,239.487 599.523,218.469 587.545,209.654C577.717,202.272 553.891,209.173 550.595,213.602C544.101,222.331 543.471,238.365 542.995,239.078C542.995,239.078 533.934,245.775 530.978,251.552C526.411,260.687 519.708,260.952 517.424,251.682C517.021,249.936 513.839,247.652 511.153,246.443C508.734,245.368 506.113,242.49 505.172,241.281C502.62,238.191 500.539,239.726 493.15,245.771L486.633,250.382L486.433,249.13L485.896,233.68C485.09,214.334 486.433,204.259 491.001,197.676C492.882,194.854 495.972,189.615 497.852,185.853C502.017,177.524 508.063,171.075 515.049,167.314C523.378,162.88 547.694,163.283 574.16,168.389C585.311,170.538 596.999,172.285 600.357,172.285C606,172.419 606.403,172.15 606.403,168.792C606.403,163.418 609.762,161 619.3,159.656C629.242,158.178 640.392,160.059 644.557,163.821C648.587,167.717 655.036,191.765 658.663,217.424C660.426,229.944 661.727,242.907 662.585,255.887C662.213,251.632 661.729,249.145 661.138,249.234C655.227,249.905 650.871,249.264 647.378,245.368L643.482,241.203C643.482,241.203 638.306,246.676 632.261,247.563C628.637,248.095 623.33,244.428 623.33,244.428C621.229,245.461 620.758,248.18 619.07,249.671C613.521,254.573 611.508,257.594 605.597,246.309C602.416,232.726 598.706,234.687 597.026,239.487" style="fill:rgb(106,139,104);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="y" transform="matrix(0.994804,0,0,1,0.995008,0)">
|
||||
<g id="y_mid" transform="matrix(1,0,0,1,0.799493,0.199139)">
|
||||
<path d="M193.432,190.684C193.268,190.41 191.29,186.27 190.965,180.068C190.35,168.365 191,150.35 191,149.5C191,146 193.8,138.1 196.8,133.4C199.6,128.8 210.1,121.4 216.2,119.6C218.2,119 230.6,117.1 235,119.1C240.6,121.6 243.6,124.4 246.2,129.4C248.6,134.1 248.2,138.2 243.9,152C242.3,157.2 241,162.2 241,163.1C241,165.6 245.7,170.8 249.9,172.9C260.2,178.1 279.9,177.5 289.1,171.8C294,168.9 297,164.8 297,161.4C297,160.4 295.4,156.3 293.5,152.3C288.9,143.1 288.1,136.7 290.9,132.3C295.3,125.3 311.8,115.4 320.8,114.3C330.4,113.2 339.3,119.5 347.6,133.5C352.1,140.9 359.044,156.7 359.044,161.4C359.144,164.9 362.322,218.917 361.922,218.917C361.622,218.917 361,222.7 360.7,227.3C359.7,242.8 355.4,260.6 349.7,273C344.2,285.2 343.5,286.2 336.9,292.4C321.2,306.9 303.8,313 278.2,313C245.9,313 218.3,302.8 201.3,284.7C193.4,276.2 190.6,269.3 191.3,259.7C192.2,246.7 201.8,232.5 211.4,230.1C218.2,228.4 230.5,230.6 237,234.7C239.9,236.5 243.9,241 244,242.5C244,244.8 250.3,250.9 253.7,252.1C263,255.1 283.5,249.3 291.6,241.4C299.8,233.3 300.6,227.9 294.3,224.7C288.6,221.8 283.7,221.9 268.8,225.1C252.3,228.6 243.2,229 231.1,226.6C214,223.3 206.1,217.3 198.5,201.7C196,196.6 193.553,190.886 193.432,190.684Z" style="fill:rgb(0,196,208);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="y_bottom" transform="matrix(0.744353,0,0,0.744353,-1.87816,0.159385)">
|
||||
<path d="M267.39,327.472C267.46,327.35 275.371,321.969 279.139,322.885C281.02,323.288 285.453,326.512 288.946,329.871C294.723,335.648 295.395,335.917 299.291,334.573C301.575,333.767 306.277,330.946 309.635,328.393C317.293,322.482 320.786,322.348 324.682,327.587C326.428,329.871 328.444,331.617 329.25,331.617C330.19,331.617 333.146,333.23 335.967,335.11C342.819,339.947 350.342,341.156 363.239,339.544C380.972,337.394 382.585,336.991 385.943,333.901C387.824,332.289 391.183,329.468 393.467,327.587C395.885,325.706 400.184,322.213 403.139,319.929C411.066,313.347 418.992,314.287 418.992,321.676C418.992,323.288 419.529,324.9 420.335,325.169C421.007,325.438 421.813,326.915 422.082,328.528C422.888,333.901 425.709,335.782 432.292,335.513C439.681,335.11 441.831,334.036 450.429,326.512C461.042,317.243 466.147,317.646 468.297,327.99C469.103,332.021 473.267,335.648 477.163,335.648C478.234,335.648 479.515,336.385 480.074,337.3C481.612,336.679 483.084,337.986 483.014,338.272C480.464,348.718 477.159,358.64 473.401,366.815C466.012,383.205 465.072,384.548 456.205,392.878C435.113,412.358 411.737,420.553 377.344,420.553C333.951,420.553 296.872,406.849 274.033,382.533C263.42,371.114 259.658,361.844 260.599,348.947C261.104,341.645 263.653,334.061 267.39,327.472Z" style="fill:rgb(0,239,254);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="y_top" transform="matrix(0.744353,0,0,0.744353,-1.87816,0.159385)">
|
||||
<path d="M260.323,244.206C260.248,243.485 260.189,242.737 260.148,241.966C259.322,226.242 260.196,202.04 260.196,200.899C260.196,196.197 263.957,185.584 267.988,179.269C271.749,173.089 285.856,163.148 294.051,160.73C296.738,159.924 313.396,157.371 319.308,160.058C326.831,163.417 330.861,167.178 334.354,173.896C337.578,180.21 337.041,185.718 331.264,204.257C329.115,211.243 327.368,217.961 327.368,219.17C327.368,222.528 333.682,229.514 339.325,232.336C353.162,239.321 379.628,238.515 391.988,230.858C398.571,226.962 402.601,221.454 402.601,216.886C402.601,215.542 400.452,210.034 397.899,204.661C391.719,192.301 390.645,183.703 394.406,177.792C400.317,168.387 422.484,155.087 434.575,153.609C447.472,152.132 459.429,160.595 470.58,179.404C476.625,189.345 485.954,210.572 485.954,216.886C486.019,219.14 487.72,249.612 487.72,249.612C487.72,249.612 479.04,257.13 476.697,258.235C472.665,260.135 470.559,257.798 468.968,253.026C466.55,245.637 463.326,242.816 456.34,242.01C451.235,241.472 450.026,241.875 446.533,245.234C441.562,250.07 435.919,253.698 433.233,253.698C429.471,253.698 425.709,248.055 425.709,242.681C425.709,239.86 425.038,237.576 424.231,237.576C423.56,237.576 420.067,239.726 416.708,242.278C409.588,247.786 407.573,248.055 403.408,244.159L400.318,241.338L394.676,247.518C388.093,254.772 381.913,255.981 378.151,250.742C377.076,248.995 374.658,245.906 372.912,243.89C369.687,240.129 369.687,240.129 364.582,242.144C361.761,243.353 358.537,245.502 357.596,247.115C355.984,249.398 354.372,249.667 346.849,249.398C339.863,249.13 337.848,249.533 336.907,251.414C334.623,255.31 331.534,253.966 322.667,245.502C312.86,236.098 310.979,235.964 303.456,244.293C298.753,249.398 291.768,253.698 288.275,253.698C287.334,253.698 284.647,251.682 282.229,249.398C275.915,242.681 269.601,239.726 263.958,240.8C261.567,241.256 260.148,242.144 260.148,242.144C260.148,242.144 260.311,243.823 260.323,244.206Z" style="fill:rgb(0,129,138);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="P">
|
||||
<g id="p_mid" transform="matrix(1,0,0,1,-0.159349,-0.379322)">
|
||||
<path d="M66,313.1C57.5,312 51.3,310 49.1,307.5C45.5,303.4 39.5,274.1 37.5,250.5C37.1,246.7 36.7,243.3 36.5,243C35.5,241.4 34.5,213.7 34.5,189.5C34.5,161.3 32.65,141.124 56.083,126.221C65.592,120.172 87.72,114.795 121.454,117.51C157.729,120.43 174.2,129.4 180.7,136.1C186.7,142.3 187.872,144.144 191.065,153.822C192.281,157.507 191.415,172.976 191.6,180.036C191.764,186.27 192.27,192.5 191.6,198.7C190.817,205.95 189.8,212.2 186.3,223.5C184.6,228.9 177.4,238.3 170.6,243.7C168.3,245.5 166,247.4 165.4,247.9C162.9,249.9 154.5,253.2 147.2,255C142.2,256.2 130.855,257.29 123.466,257.363C116.361,257.434 107.076,258.199 103.11,259.676C101.328,260.339 99.971,261.085 98.731,263.093C98.358,263.699 99.022,267.22 99.317,268.614C100.214,272.851 100.587,275.152 101.389,278.383C102.902,284.481 106.707,299.147 104.51,303.459C100.548,311.236 90.6,313.1 82.3,313.5C76.9,313.7 69.6,313.5 66,313.1ZM123.7,210.9C135.1,206.7 142,195.2 142,180.5C142,173.8 141.8,173.1 138.5,169.3C134.3,164.4 128.8,162 119.9,161.3C103,159.9 92.2,169.4 91.2,186.7C90.8,193.1 91.1,194.5 93.4,198.4C99.7,209.2 113.3,214.8 123.7,210.9Z" style="fill:rgb(191,0,179);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<path id="p_bottom" d="M98.4,309.2C91.07,313.505 79.043,314.066 67.094,313.199C61.497,312.793 49.5,309.727 47.8,305.527C45.1,298.927 40.781,279.135 38.381,260.035C37.381,252.635 38.2,251.6 39.8,249.5C43.3,245.1 51.1,239 53.3,239C54.6,239 57,240.3 58.8,242C63.6,246.4 66,246.6 71.5,243.4C74.1,241.9 76.4,240.1 76.7,239.4C77,238.6 77.8,238 78.5,238C79.1,238 80.5,237.1 81.5,236C83.9,233.3 88.6,233.4 90,236.1C90.7,237.2 91,240 90.8,242.3L90.5,246.5L95.4,246.4C99,246.4 100.6,245.9 101.9,244.3C103.7,242 107.1,240 109.4,240C110.2,240 111.4,241.6 112.1,243.5C113.6,247.6 114.7,247.5 121.5,242.9C128.1,238.5 132.3,239.4 133.4,245.5C134.1,248.9 134.2,249 139,249C143.5,249 144.3,248.6 148.5,244.6C152.9,240.3 156.6,238.2 157.7,239.4C158,239.7 158.5,241.4 158.9,243.2C159.4,245.5 160.2,246.6 162,247L164.683,247.897C164.683,247.897 163.185,248.928 161.377,249.743C158.626,250.983 155.11,252.213 154.7,252.4C149,255 137.7,256.7 124.4,256.9C107.4,257.2 102.3,259.117 98.5,262.9C98.212,264.732 99.6,271.5 101.6,279.6C103.6,287.8 105.2,296.2 105.3,298.2C105.5,302.4 102.9,306.6 98.4,309.2Z" style="fill:rgb(237,0,223);fill-rule:nonzero;"/>
|
||||
<g id="p_top" transform="matrix(0.744353,0,0,0.744353,-0.610017,-0.116225)">
|
||||
<path d="M49.619,242.099C47.214,240.103 46.19,237.641 47.458,220.097C47.854,214.616 48.739,207.932 50.114,202.532C58.737,168.674 94.056,153.306 155.334,156.748C219.585,160.358 250.468,177.263 257.292,206.299C258.589,211.816 258.238,216.423 258.252,221.969C258.255,223.054 257.895,227.086 257.918,233.93C257.931,237.542 258.025,242.243 258.055,242.732C257.078,243.011 251.337,246.879 249.916,246.583C248.495,246.287 245.572,244.647 243.422,242.938C236.122,237.137 224.486,240.586 217.454,250.635C209.612,261.843 202.655,259.252 199.584,243.98C199.011,241.13 191.289,238.099 191.289,236.256C191.289,229.648 182.534,222.56 180.114,221.335C172.905,217.689 163.343,215.524 153.974,216.339C139.038,217.636 122.995,228.356 122.995,252.627C122.995,259.04 113.957,244.373 114.718,242.25C115.654,239.641 111.922,241.155 108.287,244.859C103.361,249.878 92.087,257.247 90.353,256.582C87.407,255.451 90.007,247.061 94.723,242.48C99.323,238.014 98.077,235.576 92.823,238.761C90.995,239.869 86.674,241.791 83.219,243.033C78.693,244.66 76.129,246.311 74.044,248.944C68.344,256.141 51,252.863 51,244.588C51,243.849 50.379,242.729 49.619,242.099Z" style="fill:rgb(152,0,143);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="e1" serif:id="e" transform="matrix(1.43823,0,0,1.43823,-549.373,239.665)">
|
||||
<g id="e-shadow" transform="matrix(0.744353,0,0,0.744353,-1.87816,0.159385)">
|
||||
<path d="M1161.47,407.188C1143.12,390.566 1134.18,360.225 1130.7,335.715C1127.31,311.881 1125.42,237.207 1141.98,209.558C1148.97,198.556 1165.01,183.286 1175.53,174.05C1182.12,168.269 1200.67,158.118 1209.12,155.481C1268.43,136.969 1328.89,170.649 1358.63,222.959C1370.14,243.212 1371.18,267.401 1373.26,289.896C1373.97,297.61 1374.55,299.828 1368.76,305.69C1367.38,307.088 1359.91,309.888 1360.87,310.456C1362.22,311.256 1370.29,313.789 1372.51,316.185C1377.62,321.709 1375.37,337.912 1373.56,344.025C1366.05,369.409 1355.27,388.28 1328.64,416.762C1307.42,439.455 1284.32,447.168 1251.85,447.17C1199.55,447.173 1171.68,416.438 1161.47,407.188ZM1245.62,341.29C1244.21,340.763 1239.45,338.913 1240.01,337.967C1240.65,336.892 1246.99,337.11 1248.94,337.059C1252.79,336.96 1260.71,336.771 1261.74,337.797C1262.32,338.381 1260.78,340.517 1260.26,341.156C1257.71,344.112 1253.41,344.246 1245.62,341.29Z" style="fill:rgb(0,1,0);"/>
|
||||
</g>
|
||||
<path id="e-mid" d="M915.4,310C890.7,304.2 871.7,292.5 859.5,275.5C854.2,268 848.143,255.637 847.1,252.2C843.25,239.518 846.7,190.7 848,184.3C854.2,154.4 873.2,132.4 901.4,122.7C909.7,119.9 911.6,119.6 922.5,119.6C946.9,119.7 965,127.7 984.3,147.2C991.9,154.8 994.8,158.6 997.2,163.8C998.9,167.5 1001.3,172.1 1002.5,174C1005.8,179.4 1009,194 1009.7,207C1010.2,217 1010.1,218.8 1008.6,220.2C1004.6,224.3 989.2,226 957,226C935.5,226.1 902.8,224.6 901.1,223.6C900.7,223.3 899.4,223.7 898.4,224.5C896.8,225.6 896.5,227 896.6,232.7C896.8,240.8 898.2,243.9 904.2,249.6C910,255.1 914,257.4 923.4,260.4C933.6,263.8 938.6,263.8 943.5,260.4C948.3,257.2 950.1,254.9 954,247.9C957.6,241.1 959.3,240.3 971.5,239.6C976.5,239.2 984.7,238.5 989.8,237.9C1001.6,236.4 1009.8,237.1 1011.6,239.5C1015.6,245 1007.61,267.208 999.6,278C990.85,289.783 973.133,304.867 959.1,310.2C945.483,315.375 926.7,312.6 915.4,310ZM953.301,188.795C960.3,185.245 960.401,182.995 954.301,177.295C951.701,174.995 946.501,171.395 942.701,169.395C933.201,164.395 926.301,164.295 918.001,168.995C908.701,174.195 903.101,181.095 905.501,184.395C907.401,186.995 913.201,190.095 917.601,190.895C920.201,191.395 928.201,191.695 935.301,191.495C946.801,191.295 948.901,190.995 953.301,188.795Z" style="fill:rgb(199,198,149);fill-rule:nonzero;"/>
|
||||
<path id="e-bottom" d="M915.4,310C890.7,304.2 871.7,292.5 859.5,275.5C854.2,268 848.643,256.913 847.099,252.006C846.316,249.515 845.963,246.467 845.849,244.662C845.849,244.662 850.035,243.131 852.171,241.133C854.492,238.961 857.52,234.318 859.421,233.824C863.646,232.725 867.463,245.149 868.323,245.671C869.184,246.193 878.128,246.496 879.014,245.471C883.406,240.386 890.428,236.145 893.431,240.239C895.241,242.707 897.537,247.018 900.157,248.101C901.106,248.493 902.327,248.032 902.327,248.032C902.327,248.032 904.74,250.108 904.913,250.268C910.341,255.292 914.39,257.524 923.4,260.4C933.6,263.8 938.6,263.8 943.5,260.4C947.145,257.97 949.06,256.059 951.478,252.215C952.245,250.997 957.62,253.098 965.253,249.516C976.375,244.298 977.437,240.052 981.251,242.813C985.726,246.054 987.611,245.008 993.844,245.324C1004.38,245.859 1005.31,237.213 1008.93,238.352C1010.13,238.732 1011.15,238.9 1011.6,239.5C1015.6,245 1007.61,267.208 999.6,278C990.85,289.783 973.133,304.867 959.1,310.2C945.483,315.375 926.7,312.6 915.4,310Z" style="fill:rgb(255,254,191);fill-rule:nonzero;"/>
|
||||
<path id="e-top" d="M1006.3,184.38C1006.56,185.396 1000.28,179.352 993.999,180.776C981.283,183.657 983.188,189.019 978.097,189.873C971.966,190.902 967.482,179.035 966.858,181.812C965.881,186.162 963.835,190.772 957.481,186.227C957.127,185.974 959.509,185.207 958.376,182.235C956.295,176.779 938.186,164.162 927.852,165.608C916.427,167.206 903.439,178.535 905.164,183.785C905.926,186.105 905.637,190.321 900.038,190.094C890.009,189.825 889.385,179.676 882.167,180.827C875.385,181.909 871.592,192.172 867.226,195.781C864.545,197.998 862.159,187.096 854.763,187.009C851.701,186.973 850.448,189.405 849.092,190.668C848.337,191.371 847.4,191.225 847.423,190.806C847.599,187.628 847.793,185.319 848,184.3C854.2,154.4 873.2,132.4 901.4,122.7C909.7,119.9 911.6,119.6 922.5,119.6C946.9,119.7 965,127.7 984.3,147.2C991.9,154.8 994.8,158.6 997.2,163.8C998.9,167.5 1001.3,172.1 1002.5,174C1003.84,176.188 1005.16,179.888 1006.3,184.38Z" style="fill:rgb(148,147,111);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="c" transform="matrix(0.312039,0,0,0.312039,390.718,399.086)">
|
||||
<g id="c-extrusion" transform="matrix(1.02371,0,0,1,-0.0419524,0)">
|
||||
<path d="M721.851,550.457C727.928,550.457 827.348,533.112 830.075,576.298C836.462,677.412 730.733,884.128 643.719,942.226C595.227,974.604 509.776,1019.62 389.313,1023.31C312.833,1025.65 295.55,1021.96 261.937,1013.38C236.346,1007.04 150.829,957.052 116.958,932.22C75.565,901.872 33.515,807.197 25.506,778.197C-30.302,576.1 8.064,139.815 185.865,78.764C192.119,76.617 247.501,27.528 308.818,14.681C447.417,-14.357 522.335,18.904 534.822,24.158C595.781,49.808 653.353,90.498 660.872,96.816C668.39,103.134 756.34,187.743 787.01,250.792C798.526,274.467 805.342,296.115 812.092,339.024C835.733,489.315 490.214,504.804 477.641,401.466C475.891,387.082 466.894,342.731 456.232,332.791C439.136,316.855 442.025,311.346 402,314.612C351.26,318.752 329.799,353.696 326.218,394.37C315.165,519.909 301.873,569.753 352.679,610.82C362.298,618.595 411.291,670.367 464.573,651.936C500.5,639.508 508.146,590.677 513.668,585.155C518.691,580.132 522.063,577.845 526.68,573.227C533.254,566.653 579.914,558.047 596.074,558.047C599.784,558.047 633.609,558.462 634.024,558.047C638.412,553.659 669.719,560.303 673.058,556.963C678.054,551.967 710.725,550.457 721.851,550.457Z" style="fill:rgb(0,1,0);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="c-middle" transform="matrix(1.02371,0,0,1,-0.0419524,0)">
|
||||
<path d="M291,519.706C288.27,524.9 287.724,533.405 288.031,551.262C288.916,587.817 295.108,601.806 321.644,627.53C347.296,652.351 364.987,662.73 406.562,676.269C451.674,691.613 473.788,691.613 495.46,676.269C516.689,661.828 524.65,651.448 541.899,619.858C557.821,589.17 565.339,585.56 619.297,582.401C641.411,580.596 677.678,577.437 700.234,574.729C752.423,567.96 788.69,571.119 796.651,581.95C814.342,606.771 791.786,680.33 743.578,755.696C724.56,785.029 644.95,864.907 619.74,879.8C607.798,887.02 583.031,896.497 564.455,901.01C518.458,912.292 421.157,911.841 371.179,900.108C261.937,873.933 177.904,821.132 123.946,744.413C100.505,710.567 76.622,664.535 69.103,639.263C50.742,622.578 51.964,364.924 73.084,332.839C100.505,197.904 184.538,98.621 309.26,54.846C345.97,42.21 354.373,40.856 402.581,40.856C510.497,41.307 590.549,77.41 675.909,165.411C709.522,199.709 722.348,216.858 732.963,240.325C740.482,257.023 751.096,277.782 756.404,286.356C770.999,310.726 791.222,347.507 768.566,382.281C746.071,416.806 558.984,414.773 552.464,388C545.983,361.388 535.596,349.417 531,317C517.625,222.658 355.13,238.706 317,302C287.5,350.969 291,519.706 291,519.706Z" style="fill:rgb(153,70,242);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="c-bottom" transform="matrix(4.52766,0,0,4.51288,-3764.68,-498.884)">
|
||||
<path d="M930.5,311C917.7,310.3 914.2,309.7 902.5,305.9C876.6,297.5 853.2,273.9 846.8,249.7C846.8,249.7 845.894,245.341 846.511,242.24C846.796,240.806 850.5,240.4 850.5,240.4C853.3,237.9 856.6,235.2 857.9,234.3C860.1,232.7 860.3,232.7 862.1,235.1C863.1,236.4 864.7,239.2 865.6,241.3C867.2,244.9 867.5,245 872.5,245C877,245 878,244.6 881,241.5C883.4,239 885.3,238 887.5,238C891.1,238 892.8,239.2 895.9,243.8C897.1,245.5 898.6,247 899.2,247C899.7,247 902.3,248.8 904.8,251.1C910.3,255.9 918.9,260.1 928.2,262.6C937.2,265 941.7,263.7 948.1,256.9C951,253.9 953.6,252 955,252C956.9,252 969.5,246.2 974.9,242.9C976.4,241.9 977.9,242 982.1,243.2C985.1,244 989.5,244.6 992,244.4C997.3,244.1 1003.9,241.5 1004.7,239.5C1006.2,235.3 1013,239.7 1013,244.8C1013,256.1 999.2,280.6 985.3,294.1C974.6,304.5 965.9,309.1 954.5,310.5C944.9,311.6 943.4,311.7 930.5,311Z" style="fill:rgb(198,146,254);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="c-top" transform="matrix(1.02371,0,0,1,-0.0419524,0)">
|
||||
<path d="M65.546,358.465C65.203,360.038 69.738,337.922 73.084,332.839C100.505,197.904 184.538,98.621 309.26,54.846C345.97,42.21 354.373,40.856 402.581,40.856C510.497,41.307 590.549,77.41 675.909,165.411C709.522,199.709 722.348,216.858 732.963,240.325C740.482,257.023 787.585,339.53 751.194,280.69C738.368,277.982 702.522,280.239 683.504,289.716C670.236,296.034 656.083,305.511 651.66,310.475C639.719,324.014 621.585,321.306 603.894,303.254C589.299,288.813 588.414,288.362 585.761,296.936C582.974,305.822 540.505,306.909 531,306.227C531,306.227 530.735,309.837 530.802,315.677C516.101,222.809 354.951,239.003 317,302C310.99,311.977 306.349,326.926 302.77,344.406L304,325.997C293.036,325.642 271.03,351.475 269.013,348.183C260.61,335.095 230.977,313.434 221.689,313.434C210.632,313.434 181.884,342.767 166.847,368.491C157.117,385.64 150.04,384.286 130.58,363.075C112.447,343.219 97.852,340.06 79.718,352.244L65.546,358.465Z" style="fill:rgb(104,7,207);"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="snake-tail">
|
||||
<path id="snake_tail_base" d="M359.539,568.196C376.328,592.171 434.458,633.823 472.406,645.044C518.279,658.609 587.405,660.336 679.897,656.156C766.077,652.261 877.439,609.231 885.968,606.044C946.203,583.541 988.401,586.899 1002.77,588.423C1054.38,593.898 1092.66,618.872 1105.56,652.899C1107.03,656.798 1107.96,661.403 1108.11,662.156C1115.54,698.952 1092.31,745.481 1006.45,759.564C995.342,761.385 982.115,762.218 979.991,762.352C947.147,764.422 916.417,761.664 900.568,760.005C900.027,759.949 897.098,759.621 897.096,759.619C896.888,759.415 896.68,759.21 896.472,759.005L897.086,758.381C920.666,755.248 960.94,749.126 998.448,734.044C1001.31,732.895 1040.04,718.757 1054.57,696.061C1062.67,683.412 1057.6,676.782 1056.5,675.201C1056.44,675.115 1056.39,675.039 1055.73,674.157L1055.72,674.162C1046.89,661.435 1021.07,652.141 985.406,657.389C970.846,659.532 947.275,664.381 914.644,682.241C888.624,696.484 860.366,709.234 855.562,711.402C791.611,740.257 741.065,754.86 723.718,760.028C655.604,780.321 608.2,785.752 597.768,787.339C538.289,796.383 497.033,794.764 478.312,794.054C412.814,791.57 368.605,777.343 347.322,770.155C284.795,749.036 228.899,704.313 207.141,681.184" style="fill:rgb(240,204,0);stroke:black;stroke-width:5px;"/>
|
||||
<g id="snake_tail_light" transform="matrix(1,5.64119e-17,-3.05311e-16,1.01623,2.04636e-12,-12.3165)">
|
||||
<path d="M896.676,759.017L897.074,758.592C951.201,752.838 984.112,741.815 992.331,739.065C1015.5,731.312 1029.28,723.735 1036.57,719.259C1037.44,718.722 1042.98,714.485 1047.89,709.526C1065.93,691.322 1061.39,679.41 1059.79,675.375C1059.07,673.557 1058.08,671.773 1057.91,671.47C1057.67,671.036 1057.64,670.094 1056.18,667.794C1050.75,659.228 1037.44,650.208 1025.71,645.707C1025.23,645.522 1021.8,644.491 1015.78,643.683C997.914,641.282 974.998,641.164 974.948,641.163C972.129,641.103 969.766,640.979 962.226,641.773C931.009,645.062 898.749,656.775 888.367,660.635C887.104,661.105 877.432,665.466 876.485,665.893C855.906,675.173 822.54,687.708 819.947,688.741C812.868,691.56 799.621,697.347 786.188,702.253C739.683,719.239 693.323,727.941 685.571,729.433C653.385,735.629 626.433,738.765 608.696,740.444C604.338,740.856 589.619,741.536 578.085,741.82C522.481,743.188 469.149,738.496 418.693,722.692C408.655,719.548 366.963,709.208 319.424,677.321C295.988,661.6 277.151,645.53 259.994,628.072C254.961,622.951 248.884,616.425 247.698,614.923C247.43,614.582 244.53,610.909 244.369,610.65C242.42,607.502 240.145,604.529 238.523,601.207C236.944,597.975 235.712,594.561 234.814,591.085C233.931,587.661 233.401,584.133 233.206,580.605C233.012,577.1 233.166,573.56 233.653,570.083C234.14,566.605 234.963,563.156 236.112,559.833C237.269,556.489 238.748,553.233 240.539,550.171C242.357,547.063 244.481,544.104 246.889,541.411C246.901,541.399 255.12,533.868 255.128,533.863C258.326,531.945 261.347,529.707 264.723,528.11C268.008,526.556 271.477,525.344 275.01,524.461C278.49,523.591 282.075,523.07 285.66,522.878C289.222,522.687 292.819,522.839 296.353,523.318C299.887,523.797 303.391,524.607 306.769,525.738C310.167,526.876 313.476,528.331 316.588,530.094C319.746,531.883 322.753,533.973 325.489,536.343C331.277,541.355 330.94,541.68 335.67,547.673C336.608,548.86 340.725,555.506 348.123,565.17C365.483,587.848 380.515,600.249 383.738,602.966C408.038,623.447 431.285,634.651 445.907,640.896C445.944,640.912 450.996,642.83 457.753,645.007C505.526,660.404 557.255,663.368 603.857,662.89C607.323,662.854 662.21,665.356 729.772,655.323C763.895,650.256 782.974,644.572 790.099,642.64C801.012,639.682 801.022,639.727 807.413,637.805C851.965,624.408 856.102,622.046 869.867,617.329C873.303,616.152 888.961,609.816 910.249,603.841C936.572,596.452 955.258,594.205 966.707,593.42C972.364,593.032 980.77,593.425 981.991,593.482C998.957,594.276 1026.6,596.67 1040.75,601.406C1041.5,601.658 1054.02,605.899 1068.12,615.376C1078.15,622.112 1098.06,637.597 1103.68,659.958C1104.03,661.376 1104.31,665.626 1104.36,668.049C1104.77,685.998 1098.6,715.97 1055.73,734.009C1050.56,736.185 1047.64,737.049 1046.34,737.612C1034.07,742.941 1007.63,752.855 957.55,757.446C930.044,759.967 906.841,759.606 897.11,759.408C896.794,759.402 896.909,759.227 896.676,759.017Z" style="fill:rgb(254,227,45);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="controller" transform="matrix(1.74196,0.213885,-0.213885,1.74196,-1198.25,-299.016)">
|
||||
<g id="controller_shadow" transform="matrix(0.565541,-0.0694397,0.0694397,0.565541,696.515,84.3871)">
|
||||
<path d="M1419.81,473.179C1401.86,469.487 1386.35,459.968 1375.04,446.884C1374.98,446.81 1374.85,446.662 1374.85,446.662L1259.66,432.449C1259.66,432.449 1259.45,432.597 1259.34,432.671C1243.52,443.799 1223.68,449.326 1202.99,446.782C1158.7,441.334 1127.16,400.948 1132.61,356.65C1138.06,312.352 1178.44,280.81 1222.74,286.257L1446.05,313.721C1466.36,316.219 1484,326.07 1496.61,340.276C1460.72,398.605 1438.4,442.425 1419.81,473.179Z" style="fill-opacity:0.15;"/>
|
||||
</g>
|
||||
<g id="controller_base" transform="matrix(1,1.38778e-17,-1.38778e-17,1,0.0303899,0.00185873)">
|
||||
<path d="M1543.54,151.836C1568.96,151.841 1589.6,172.491 1589.6,197.922C1589.59,223.352 1568.94,243.995 1543.52,243.99C1531.63,243.988 1520.8,239.476 1512.62,232.076C1512.58,232.039 1512.5,231.964 1512.5,231.964L1446.37,231.924C1446.37,231.924 1446.26,232.023 1446.21,232.072C1438.03,239.464 1427.2,243.967 1415.32,243.965C1389.89,243.96 1369.25,223.31 1369.26,197.879C1369.26,172.448 1389.91,151.806 1415.34,151.811C1428.76,151.814 1531.15,151.834 1543.54,151.836Z" style="fill:rgb(203,207,204);stroke:black;stroke-width:2.65px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="panel-right">
|
||||
<g id="back" transform="matrix(1.25194,6.94183e-05,-6.94266e-05,1.25209,702.158,-210.326)">
|
||||
<path d="M671.126,294.011C688.787,293.917 703.201,308.18 703.295,325.841C703.388,343.502 689.126,357.916 671.465,358.01C653.804,358.104 639.389,343.841 639.296,326.18C639.202,308.519 653.465,294.104 671.126,294.011Z" style="fill:rgb(70,93,99);"/>
|
||||
</g>
|
||||
<g id="labels">
|
||||
<g id="X" transform="matrix(0.715199,3.96568e-05,-3.96615e-05,0.715285,1073.74,-61.4904)">
|
||||
<path d="M671.925,328.927L674.297,325.264L672.113,321.931L673.764,321.922L675.178,324.162L676.541,321.907L678.177,321.899L676.019,325.308L678.429,328.893L676.726,328.902L675.162,326.491L673.619,328.918L671.925,328.927Z" style="fill:rgb(200,208,210);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="Y" transform="matrix(0.715199,3.96568e-05,-3.96615e-05,0.715285,1026.13,-24.0172)">
|
||||
<path d="M674.752,329.265L674.736,326.321L672.153,322.284L673.808,322.275L675.469,325.034L677.067,322.258L678.694,322.249L676.144,326.323L676.16,329.258L674.752,329.265Z" style="fill:rgb(200,208,210);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="B" transform="matrix(0.715199,3.96568e-05,-3.96615e-05,0.715285,1043.41,-8.06965)">
|
||||
<path d="M673,322.152L675.797,322.137C676.35,322.134 676.763,322.155 677.035,322.2C677.307,322.244 677.551,322.339 677.767,322.484C677.982,322.63 678.162,322.823 678.307,323.066C678.451,323.309 678.524,323.581 678.526,323.883C678.528,324.211 678.441,324.512 678.266,324.786C678.091,325.061 677.852,325.267 677.551,325.406C677.978,325.528 678.307,325.737 678.537,326.035C678.768,326.333 678.884,326.684 678.886,327.088C678.888,327.406 678.816,327.716 678.669,328.017C678.523,328.319 678.322,328.56 678.067,328.741C677.812,328.922 677.497,329.034 677.122,329.078C676.887,329.104 676.319,329.123 675.419,329.134L673.038,329.147L673,322.152ZM674.419,323.309L674.428,324.926L675.353,324.921C675.904,324.918 676.246,324.908 676.379,324.892C676.621,324.862 676.81,324.777 676.948,324.638C677.086,324.499 677.154,324.317 677.153,324.091C677.151,323.875 677.091,323.699 676.971,323.565C676.851,323.43 676.673,323.349 676.438,323.322C676.298,323.307 675.895,323.301 675.23,323.304L674.419,323.309ZM674.434,326.09L674.444,327.961L675.751,327.954C676.26,327.951 676.583,327.935 676.72,327.906C676.929,327.867 677.1,327.773 677.231,327.624C677.362,327.475 677.427,327.277 677.426,327.029C677.425,326.819 677.373,326.641 677.27,326.495C677.168,326.349 677.02,326.244 676.827,326.178C676.634,326.112 676.217,326.081 675.574,326.084L674.434,326.09Z" style="fill:rgb(200,208,210);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g id="A" transform="matrix(0.715199,3.96568e-05,-3.96615e-05,0.715285,1092.32,-44.9897)">
|
||||
<path d="M679.066,328.752L677.53,328.76L676.911,327.174L674.115,327.189L673.546,328.781L672.047,328.789L674.735,321.78L676.228,321.772L679.066,328.752ZM676.451,325.998L675.474,323.408L674.543,326.008L676.451,325.998Z" style="fill:rgb(200,208,210);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="button-set2">
|
||||
<g id="reduttonframe1" transform="matrix(0.756173,0.897271,-0.581386,0.490079,1194.96,-604.73)">
|
||||
<path d="M733.551,309.883C733.526,302.643 729.697,296.797 725.006,296.836C720.315,296.874 716.526,302.782 716.551,310.022L716.677,346.788C716.702,354.027 720.531,359.873 725.222,359.835C729.913,359.796 733.702,353.888 733.677,346.649L733.551,309.883Z" style="fill:rgb(209,209,205);"/>
|
||||
</g>
|
||||
<g id="redbutton2" transform="matrix(0.645468,0.76591,-0.765818,0.645545,1381.18,-536.495)">
|
||||
<path d="M678.124,355.079C682.497,355.056 686.065,358.587 686.088,362.959C686.111,367.331 682.581,370.9 678.208,370.923C673.836,370.946 670.267,367.415 670.244,363.043C670.221,358.671 673.752,355.102 678.124,355.079Z" style="fill-opacity:0.5;"/>
|
||||
</g>
|
||||
<g id="redbutton21" serif:id="redbutton2" transform="matrix(0.645468,0.76591,-0.765818,0.645545,1382.78,-538.55)">
|
||||
<path d="M678.124,355.079C682.497,355.056 686.065,358.587 686.088,362.959C686.111,367.331 682.581,370.9 678.208,370.923C673.836,370.946 670.267,367.415 670.244,363.043C670.221,358.671 673.752,355.102 678.124,355.079Z" style="fill:rgb(190,0,3);"/>
|
||||
</g>
|
||||
<g id="redbutton1" transform="matrix(0.645468,0.76591,-0.765818,0.645545,1401.09,-553.279)">
|
||||
<path d="M677.987,355.079C682.359,355.056 685.927,358.587 685.951,362.959C685.974,367.332 682.443,370.9 678.07,370.923C673.698,370.946 670.13,367.416 670.106,363.043C670.083,358.671 673.614,355.102 677.987,355.079Z" style="fill-opacity:0.5;"/>
|
||||
</g>
|
||||
<g id="redbutton11" serif:id="redbutton1" transform="matrix(0.645468,0.76591,-0.765818,0.645545,1402.7,-555.334)">
|
||||
<path d="M677.987,355.079C682.359,355.056 685.927,358.587 685.951,362.959C685.974,367.332 682.443,370.9 678.07,370.923C673.698,370.946 670.13,367.416 670.106,363.043C670.083,358.671 673.614,355.102 677.987,355.079Z" style="fill:rgb(190,0,3);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="button-set1">
|
||||
<g id="redbuttonframe2" transform="matrix(0.756173,0.897271,-0.581386,0.490079,1174.3,-621.108)">
|
||||
<path d="M733.575,310.063C733.55,302.823 729.721,296.977 725.03,297.015C720.339,297.054 716.55,302.962 716.575,310.202L716.701,346.967C716.726,354.207 720.555,360.053 725.246,360.015C729.937,359.976 733.726,354.068 733.701,346.828L733.575,310.063Z" style="fill:rgb(209,209,205);"/>
|
||||
</g>
|
||||
<g id="redbutton4" transform="matrix(0.645468,0.76591,-0.765818,0.645545,1360.52,-552.873)">
|
||||
<path d="M678.152,355.215C682.525,355.192 686.093,358.723 686.116,363.096C686.14,367.468 682.609,371.036 678.236,371.06C673.864,371.083 670.295,367.552 670.272,363.179C670.249,358.807 673.78,355.239 678.152,355.215Z" style="fill-opacity:0.5;"/>
|
||||
</g>
|
||||
<g id="redbutton41" serif:id="redbutton4" transform="matrix(0.645468,0.76591,-0.765818,0.645545,1362.13,-554.928)">
|
||||
<path d="M678.152,355.215C682.525,355.192 686.093,358.723 686.116,363.096C686.14,367.468 682.609,371.036 678.236,371.06C673.864,371.083 670.295,367.552 670.272,363.179C670.249,358.807 673.78,355.239 678.152,355.215Z" style="fill:rgb(190,0,3);"/>
|
||||
</g>
|
||||
<g id="redbutton3" transform="matrix(0.645468,0.76591,-0.765818,0.645545,1380.43,-569.657)">
|
||||
<path d="M678.015,355.216C682.387,355.193 685.955,358.724 685.979,363.096C686.002,367.468 682.471,371.037 678.099,371.06C673.726,371.083 670.158,367.552 670.135,363.18C670.111,358.808 673.642,355.239 678.015,355.216Z" style="fill-opacity:0.5;"/>
|
||||
</g>
|
||||
<g id="redbutton31" serif:id="redbutton3" transform="matrix(0.645468,0.76591,-0.765818,0.645545,1382.04,-571.712)">
|
||||
<path d="M678.015,355.216C682.387,355.193 685.955,358.724 685.979,363.096C686.002,367.468 682.471,371.037 678.099,371.06C673.726,371.083 670.158,367.552 670.135,363.18C670.111,358.808 673.642,355.239 678.015,355.216Z" style="fill:rgb(190,0,3);"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="panel-middle">
|
||||
<g id="button2_shadow" transform="matrix(0.7629,-0.596793,0.50169,0.641485,825.176,317.256)">
|
||||
<path d="M595.758,371.768C595.756,374.34 593.999,376.426 591.836,376.424L578.232,376.41C576.07,376.407 574.316,374.317 574.318,371.745C574.319,369.173 576.077,367.087 578.239,367.089L591.843,367.104C594.005,367.106 595.759,369.196 595.758,371.768Z" style="fill-opacity:0.5;"/>
|
||||
</g>
|
||||
<g id="button1_shadow" transform="matrix(0.762933,-0.596751,0.501656,0.641513,849.213,314.296)">
|
||||
<path d="M593.889,374.588C593.889,377.16 592.133,379.248 589.971,379.247L576.367,379.246C574.204,379.245 572.449,377.157 572.449,374.585C572.449,372.013 574.205,369.925 576.368,369.925L589.971,369.927C592.134,369.927 593.889,372.016 593.889,374.588Z" style="fill-opacity:0.5;"/>
|
||||
</g>
|
||||
<g id="button2" transform="matrix(0.7629,-0.596793,0.50169,0.641485,826.704,315.3)">
|
||||
<path d="M594.538,371.767C594.539,369.996 593.331,368.556 591.842,368.555L578.238,368.54C576.749,368.539 575.539,369.976 575.538,371.747C575.536,373.518 576.744,374.957 578.233,374.959L591.837,374.973C593.326,374.974 594.536,373.538 594.538,371.767Z" style="fill:rgb(51,66,73);stroke:black;stroke-width:2.64px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="button1" transform="matrix(0.762933,-0.596751,0.501656,0.641513,850.741,312.34)">
|
||||
<path d="M592.669,374.588C592.669,372.816 591.461,371.378 589.971,371.378L576.368,371.376C574.878,371.376 573.669,372.814 573.669,374.585C573.669,376.356 574.878,377.794 576.367,377.795L589.971,377.796C591.46,377.796 592.669,376.359 592.669,374.588Z" style="fill:rgb(50,65,72);stroke:black;stroke-width:2.64px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="infobox" transform="matrix(0.427146,0.052447,-0.0524533,0.427198,1387.96,77.9999)">
|
||||
<path d="M292.484,163.35C291.66,156.627 285.532,151.838 278.809,152.662L176.592,165.191C169.869,166.015 165.08,172.142 165.904,178.865L168.891,203.228C169.716,209.951 175.843,214.741 182.566,213.917L284.783,201.388C291.506,200.564 296.295,194.436 295.471,187.713L292.484,163.35Z" style="fill:rgb(100,100,100);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="panel-left">
|
||||
<g id="d-pad">
|
||||
<g id="dpad_shadow" transform="matrix(0.998332,-0.05773,0.05773,0.998332,-11.5965,85.393)">
|
||||
<path d="M1409.57,204.851L1409.57,212.522C1409.57,216.449 1409.13,216.008 1413.06,216.009L1420.03,216.01C1423.95,216.01 1423.51,216.451 1423.51,212.524L1423.52,204.854L1431.18,204.855C1435.11,204.855 1434.67,205.296 1434.67,201.369L1434.67,194.396C1434.67,190.468 1435.11,190.91 1431.19,190.909L1423.52,190.908L1423.52,183.238C1423.52,179.31 1423.96,179.751 1420.03,179.751L1413.06,179.75C1409.13,179.749 1409.58,179.308 1409.57,183.236L1409.57,190.906L1401.9,190.905C1397.98,190.904 1398.42,190.463 1398.42,194.39L1398.42,201.363C1398.41,205.291 1397.97,204.85 1401.9,204.85L1409.57,204.851Z" style="fill-opacity:0.15;"/>
|
||||
</g>
|
||||
<g id="dpad" transform="matrix(0.998332,-0.05773,0.05773,0.998332,-9.03074,82.109)">
|
||||
<path d="M1409.57,204.851L1409.57,212.522C1409.57,216.449 1409.13,216.008 1413.06,216.009L1420.03,216.01C1423.95,216.01 1423.51,216.451 1423.51,212.524L1423.52,204.854L1431.18,204.855C1435.11,204.855 1434.67,205.296 1434.67,201.369L1434.67,194.396C1434.67,190.468 1435.11,190.91 1431.19,190.909L1423.52,190.908L1423.52,183.238C1423.52,179.31 1423.96,179.751 1420.03,179.751L1413.06,179.75C1409.13,179.749 1409.58,179.308 1409.57,183.236L1409.57,190.906L1401.9,190.905C1397.98,190.904 1398.42,190.463 1398.42,194.39L1398.42,201.363C1398.41,205.291 1397.97,204.85 1401.9,204.85L1409.57,204.851Z" style="fill:rgb(32,44,51);stroke:black;stroke-width:2.47px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="shadow1" transform="matrix(0.998332,-0.05773,0.05773,0.998332,-8.59573,82.0861)">
|
||||
<path d="M1404.38,197.522L1428.35,197.526C1429.56,197.526 1431.18,198.212 1431.18,198.212C1431.18,198.212 1431.2,197.683 1431.2,197.375L1431.2,196.227C1431.2,192.861 1431.92,193.758 1428.35,193.757L1420.24,193.772L1420.24,185.044C1420.24,181.678 1420.97,182.575 1417.39,182.574L1415.79,182.599C1412.21,182.599 1412.93,181.702 1412.93,185.068L1412.93,193.796L1404.38,193.754C1400.81,193.753 1401.53,192.856 1401.53,196.223L1401.53,197.371C1401.53,197.714 1401.52,198.076 1401.52,198.076C1401.52,198.076 1403.2,197.522 1404.38,197.522Z" style="fill:rgb(17,22,24);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="shadow2" transform="matrix(1,0,0,1,0.0303899,0.00185873)">
|
||||
<path d="M1416.31,227.099C1416.96,227.133 1423.74,227.37 1431.27,222.565C1435.87,219.629 1439.4,213.952 1439.4,213.952C1439.4,213.952 1437.11,219.468 1431.59,223.028C1424.74,227.454 1417.01,227.137 1416.31,227.099C1416.28,227.097 1416.26,227.096 1416.26,227.096C1416.26,227.096 1416.28,227.097 1416.31,227.099Z" style="fill:rgb(128,128,128);"/>
|
||||
</g>
|
||||
<g id="shadow11" serif:id="shadow1" transform="matrix(1,0,0,1,0.0303899,0.00185873)">
|
||||
<path d="M1440.8,187.23C1440.26,186.136 1439.52,184.911 1438.53,183.776C1435.8,180.65 1431.2,177.888 1427.12,176.064C1423.77,174.562 1420.01,172.858 1415.45,172.492C1411.33,172.162 1405.21,173.498 1405.21,173.498C1405.21,173.498 1417.69,168.118 1428.8,174.116C1435.62,177.8 1439.15,183.588 1440.8,187.23C1441.71,189.099 1442.04,190.584 1442.04,190.584C1442.04,190.584 1441.7,189.231 1440.8,187.23Z" style="fill:rgb(59,59,59);"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="snake-head" transform="matrix(1.74196,0.213885,-0.213885,1.74196,-1198.25,-299.016)">
|
||||
<g id="head-shadow">
|
||||
<g id="jaw_shadow" transform="matrix(0.966789,-0.000509118,0.000541645,1.02855,886.258,-166.995)">
|
||||
<path d="M569.42,389.108C573.599,388.846 591.189,392.816 601.973,392.583C621.269,392.166 625.866,390.112 629.084,390.607C644.095,392.916 646.899,404.867 645.412,412.246C643.561,421.437 636.374,436.903 599.987,436.671C558.349,436.406 552.265,415.036 553.411,405.263C554.978,391.9 564.566,389.412 569.42,389.108Z" style="fill-opacity:0.15;"/>
|
||||
</g>
|
||||
<g id="head_shadow" transform="matrix(0.565541,-0.0694397,0.0694397,0.565541,696.515,84.3871)">
|
||||
<path d="M1547.17,262.701C1547.17,262.701 1536.35,276.182 1532.38,281.213C1526.64,288.487 1515.91,289.702 1507.77,294.127C1498.91,298.942 1487.62,304.343 1479.24,310.102C1471.38,315.503 1464.59,323.65 1457.47,328.679C1450.97,333.281 1443.72,336.763 1436.57,340.278C1428.4,344.292 1418.27,349.836 1408.47,352.763C1398.66,355.69 1388.11,357.435 1377.73,357.84C1364.98,358.338 1346.48,357.539 1331.94,355.751C1317.94,354.028 1302.17,350.614 1290.5,347.112C1280.56,344.128 1270.72,339.956 1261.92,334.74C1253.11,329.525 1244.63,321.692 1237.68,315.818C1231.59,310.675 1225.4,305.541 1220.21,299.5C1214.52,292.897 1209.91,283.347 1203.59,276.202C1196.85,268.583 1187.21,260.607 1179.78,253.79C1172.96,247.525 1162.84,243.745 1159.03,235.297C1155.59,227.661 1154.69,215.841 1155.61,205.634C1156.14,202.246 1156.96,198.847 1158.07,195.448C1163.17,200.777 1167.82,205.426 1174.09,207.518C1195.65,56.069 1407.89,13.746 1500.57,141.687C1519.42,167.713 1531.85,194.242 1539.26,215.859C1547.78,240.687 1549.69,259.035 1547.17,262.701Z" style="fill-opacity:0.15;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="head_base" transform="matrix(1,1.38778e-17,-1.38778e-17,1,0.0303899,0.00185873)">
|
||||
<path d="M1484.47,23.611C1503.71,23.627 1503.94,13.26 1521.53,9.733C1531.13,7.809 1543.3,9.516 1546.57,10.36C1563.32,14.679 1569.08,31.326 1572.6,40.656C1576.37,50.617 1576.56,55.129 1581.61,66.701C1585.58,75.79 1588.48,82.31 1590.51,88.715C1592.68,95.56 1594.62,100.761 1594.62,107.772C1594.62,114.255 1593.45,122.13 1590.61,126.803C1587.87,131.316 1581.89,132.748 1577.59,135.816C1572.92,139.154 1566.91,142.993 1562.57,146.831C1558.5,150.432 1555.22,155.511 1551.55,158.849C1548.19,161.904 1544.33,164.376 1540.53,166.861C1536.19,169.698 1530.85,173.536 1525.5,175.873C1520.16,178.209 1514.32,179.928 1508.48,180.878C1501.3,182.045 1490.78,182.878 1482.43,182.876C1474.39,182.874 1465.24,182.038 1458.4,180.868C1452.57,179.871 1446.71,178.195 1441.37,175.856C1436.03,173.518 1430.69,169.677 1426.35,166.838C1422.55,164.352 1418.69,161.878 1415.34,158.823C1411.66,155.483 1408.39,150.403 1404.32,146.801C1399.98,142.96 1393.97,139.119 1389.3,135.779C1385.01,132.71 1379.02,131.275 1376.28,126.762C1373.44,122.087 1372.11,114.073 1372.28,107.729C1372.45,101.385 1374.99,94.84 1377.29,88.698C1379.8,82.021 1384.45,74.886 1387.31,67.665C1390.48,59.652 1392.56,49.579 1396.33,40.622C1400.2,31.428 1407.69,16.425 1419.46,11.157C1427.43,7.591 1441.82,8.413 1448.42,9.719C1466.03,13.208 1465.82,23.595 1484.47,23.611Z" style="fill:rgb(254,227,45);stroke:black;stroke-width:2.9px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="face-shadows" transform="matrix(1.00155,-1.38778e-17,-1.52656e-16,1.00167,894.193,-165.734)">
|
||||
<g id="shadow3" transform="matrix(0.998451,1.38332e-17,1.52165e-16,0.998331,-892.808,165.457)">
|
||||
<path d="M1521.82,12.219C1527.23,9.394 1538.79,9.481 1545.1,11.167C1551.13,12.782 1555.87,17.325 1559.67,22.34C1564.5,28.725 1565.64,26.87 1575.93,56.91C1578.26,63.681 1580.8,70.655 1582.88,75.235C1584.34,78.453 1585.51,81.112 1586.79,84.39C1588.45,88.629 1590.48,95.58 1591.22,100.666C1591.9,105.384 1592.5,110.336 1591.22,114.908C1589.93,119.486 1589.5,125.306 1585.1,128.134C1577.97,132.71 1561.1,144.367 1561.1,144.367C1559.79,142.192 1564.48,132.508 1557.88,121.126C1550.22,107.89 1542.21,104.758 1542.21,104.758C1542.21,104.758 1559.02,95.808 1561.88,71.169C1563.1,60.673 1559.36,41.955 1552.55,33.64C1541.13,19.685 1532.92,19.952 1524,19.12C1519.91,18.738 1520.21,13.064 1521.82,12.219Z" style="fill:rgb(255,223,38);"/>
|
||||
</g>
|
||||
<g id="shadow21" serif:id="shadow2" transform="matrix(0.998451,1.38332e-17,1.52165e-16,0.998331,-892.808,165.457)">
|
||||
<path d="M1489.73,26.181C1489.73,26.181 1497.4,24.469 1500.5,22.616C1505.93,19.368 1513.67,13.307 1519.81,12.617C1522.82,12.279 1520.63,15.733 1519.77,17.161C1518.47,19.303 1518.94,17.039 1508.98,26.004C1499.72,34.342 1493.84,51.231 1493.74,66.247C1493.69,73.217 1499.3,89.043 1500.75,89.284L1486.73,87.283C1486.73,87.283 1485.25,67.912 1485.72,58.235C1486.22,48.051 1489.73,26.181 1489.73,26.181Z" style="fill:rgb(240,204,0);"/>
|
||||
</g>
|
||||
<g id="shadow12" serif:id="shadow1" transform="matrix(0.998451,1.38332e-17,1.52165e-16,0.998331,-892.808,165.457)">
|
||||
<path d="M1405.32,145.622C1405.32,145.622 1390.63,134.282 1385.68,131.88C1382.04,130.116 1379.62,128.685 1378.27,126.84C1374.35,121.509 1374.05,113.99 1373.89,109.714C1373.6,101.948 1376.82,94.4 1379.12,88.301C1381.31,82.535 1384.28,77.92 1386.77,72.849C1387.2,71.954 1391.56,60.25 1391.85,59.281C1396.63,43.665 1396.04,45.384 1400.14,36.004C1405.24,24.368 1413.02,15.889 1419.26,12.845C1425.33,9.888 1437.14,10.531 1434.52,14.005C1433.35,15.56 1430.27,17.487 1424.6,21.097C1419.41,24.395 1413.77,29.993 1412.28,32.384C1409.35,37.071 1402.77,50.733 1402.43,64.479C1402.3,69.822 1404.06,80.38 1405.04,83.942C1406.61,89.608 1408.61,100.817 1408.61,103.321C1408.61,105.561 1406.55,107.298 1405.61,109.332C1404.61,111.502 1403.13,113.855 1402.6,116.344C1401.94,119.516 1401.31,124.354 1401.6,128.364C1401.94,132.871 1405.32,145.622 1405.32,145.622Z" style="fill:rgb(239,204,0);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="face-highlights" transform="matrix(1.00155,-1.38778e-17,-1.66533e-16,1.00167,895.927,-160.133)">
|
||||
<g id="highlight3" transform="matrix(0.991009,-0.121666,0.121681,0.99089,-891.119,346.576)">
|
||||
<path d="M1552.81,19.744C1554.06,17.836 1559.64,20.775 1561.12,22.839C1562.85,25.236 1563.88,31.689 1563.07,32.085C1561.92,32.65 1559.86,27.69 1558.19,25.358C1556.46,22.961 1552.32,20.496 1552.81,19.744Z" style="fill:white;"/>
|
||||
</g>
|
||||
<g id="highlight2" transform="matrix(0.991009,-0.121666,0.121681,0.99089,-891.119,346.576)">
|
||||
<path d="M1584.59,109.737C1583.34,109.289 1583.02,112.525 1582.09,115.48C1581.03,118.886 1580.42,119.824 1578.89,121.573C1574.18,126.985 1573.99,130.665 1575,130.752C1579.32,131.121 1582.1,125.084 1583.68,120.932C1584.64,118.437 1585.29,109.991 1584.59,109.737Z" style="fill:white;"/>
|
||||
</g>
|
||||
<g id="highlight1" transform="matrix(0.991009,-0.121666,0.121681,0.99089,-891.119,346.576)">
|
||||
<path d="M1473.1,23.129C1473.68,22.527 1476.81,24.424 1477.83,25.726C1478.85,27.027 1479.79,30.338 1479.21,30.94C1478.63,31.542 1475,30.067 1473.99,28.765C1472.97,27.463 1472.52,23.731 1473.1,23.129Z" style="fill:white;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="eyes">
|
||||
<g id="eye-r">
|
||||
<g id="eyeball-r" transform="matrix(1,0,0,1,0.0303899,0.00185873)">
|
||||
<path d="M1528.21,22.677C1545.14,22.68 1558.88,41.607 1558.87,64.916C1558.87,88.225 1545.12,107.146 1528.2,107.143C1511.27,107.139 1497.54,88.213 1497.54,64.904C1497.55,41.595 1511.29,22.674 1528.21,22.677Z" style="fill:white;stroke:black;stroke-width:2.77px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="pupil-r" transform="matrix(1.17746,1.11022e-16,8.32667e-17,1.17746,-268.628,-25.7873)">
|
||||
<path d="M1514.56,72.669C1519.87,72.67 1524.19,76.987 1524.19,82.303C1524.19,87.619 1519.87,91.935 1514.55,91.934C1509.24,91.933 1504.92,87.616 1504.92,82.299C1504.93,76.983 1509.24,72.668 1514.56,72.669Z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="eye-l">
|
||||
<g id="eyeball-l" transform="matrix(1,0,0,1,0.0303899,0.00185873)">
|
||||
<path d="M1437.73,22.659C1454.65,22.663 1468.39,41.589 1468.38,64.898C1468.38,88.207 1454.63,107.128 1437.71,107.125C1420.79,107.122 1407.05,88.195 1407.05,64.886C1407.06,41.577 1420.8,22.656 1437.73,22.659Z" style="fill:white;stroke:black;stroke-width:2.77px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="pupil-l" transform="matrix(1.17746,1.11022e-16,8.32667e-17,1.17746,-257.448,-25.7851)">
|
||||
<path d="M1451.56,72.656C1456.87,72.657 1461.19,76.974 1461.19,82.291C1461.19,87.607 1456.87,91.922 1451.55,91.921C1446.24,91.92 1441.92,87.603 1441.92,82.287C1441.92,76.971 1446.24,72.655 1451.56,72.656Z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="jaw">
|
||||
<g id="jaw-base" transform="matrix(0.966789,-0.000509118,0.000541645,1.02855,892.707,-175.25)">
|
||||
<path d="M569.42,389.108C573.599,388.846 591.189,392.816 601.973,392.583C621.269,392.166 625.866,390.112 629.084,390.607C644.095,392.916 646.899,404.867 645.412,412.246C643.561,421.437 636.374,436.903 599.987,436.671C558.349,436.406 552.265,415.036 553.411,405.263C554.978,391.9 564.566,389.412 569.42,389.108Z" style="fill:rgb(240,204,0);stroke:black;stroke-width:2.83px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="jaw-light" transform="matrix(0.931083,-0.000490315,0.00052164,0.990567,913.997,-159.516)">
|
||||
<path d="M587.362,396.695C592.828,396.373 597.492,396.713 604.111,396.033C614.154,394.999 620.211,392.212 627.296,391.234C634.38,390.256 640.519,394.432 643.726,399.294C647.362,404.804 646.532,409.459 645.797,412.778C642.972,425.521 631.326,433.025 602.625,432.724C591.307,432.605 585.525,431.883 577.278,426.782C571.056,422.933 566.066,412.338 569.276,405.034C572.991,396.583 582.194,396.999 587.362,396.695Z" style="fill:rgb(254,227,45);"/>
|
||||
</g>
|
||||
<g id="hilight1" transform="matrix(0.966789,-0.000509118,0.00050918,0.966905,672.291,-152.965)">
|
||||
<path d="M859.405,400.127C860.405,400.126 863.362,401.485 864.406,403.124C865.574,404.957 866.41,409.789 866.41,411.123C866.411,411.789 864.882,411.595 864.41,411.124C863.743,410.458 863.303,408.317 862.408,407.125C861.408,405.792 858.907,404.293 858.406,403.127C857.99,402.158 858.405,400.127 859.405,400.127Z" style="fill:white;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="snout" transform="matrix(1.01627,2.49019e-17,-2.49019e-17,1.01627,-24.0994,-2.4617)">
|
||||
<g id="tooth_r" transform="matrix(1,0,0,1,0.0303899,0.00185873)">
|
||||
<path d="M1532.52,170.866L1544.54,163.856L1540.52,211.936L1532.52,170.866Z" style="fill:white;stroke:black;stroke-width:2.9px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="tooth_l" transform="matrix(1,0,0,1,0.0303899,0.00185873)">
|
||||
<path d="M1430.36,170.846L1418.34,163.832L1422.34,211.913L1430.36,170.846Z" style="fill:white;stroke:black;stroke-width:2.9px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="snout_base" transform="matrix(1.16089,0.000531638,-0.000959148,2.0944,804.244,-533.637)">
|
||||
<path d="M584.086,297.961C620.512,297.97 650.077,307.836 650.067,319.978C650.056,332.12 620.474,341.97 584.047,341.961C547.621,341.951 518.056,332.085 518.067,319.943C518.077,307.801 547.659,297.951 584.086,297.961Z" style="fill:rgb(254,227,45);stroke:black;stroke-width:1.72px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="shadow13" serif:id="shadow1" transform="matrix(0.590658,0.000270496,-0.000270529,0.590729,-605.649,-55.1469)">
|
||||
<path d="M3478.21,257.973C3478.21,257.973 3427.78,276.329 3427.76,323.263C3427.73,370.198 3476.76,386.865 3476.76,386.865C3476.76,386.865 3411.18,370.19 3411.21,323.255C3411.23,276.321 3478.21,257.973 3478.21,257.973Z" style="fill:rgb(232,197,0);"/>
|
||||
</g>
|
||||
<g id="nostril-r">
|
||||
<g id="nostril_r_base" transform="matrix(1.15237,0.000527734,-0.000608997,1.32981,860.768,-268.078)">
|
||||
<path d="M564.004,297.373C571.731,297.377 578.003,300.292 578.001,303.879C577.999,307.467 571.724,310.377 563.997,310.373C556.27,310.37 549.999,307.455 550.001,303.868C550.003,300.28 556.278,297.37 564.004,297.373Z" style="fill:rgb(247,219,39);"/>
|
||||
</g>
|
||||
<g id="shadow_r" transform="matrix(0.465447,0.000213155,-0.00021318,0.465503,-114.16,3.52739)">
|
||||
<path d="M3456.32,281.48C3458.55,272.379 3473.1,265.348 3490.7,265.357C3509.83,265.366 3525.36,273.694 3525.35,283.942C3525.35,289.793 3520.28,295.013 3512.38,298.413C3512.57,297.618 3512.67,296.808 3512.67,295.985C3512.68,285.736 3497.15,277.409 3478.02,277.399C3469.81,277.395 3462.27,278.924 3456.32,281.48Z" style="fill:rgb(205,177,0);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="nostril-l">
|
||||
<g id="nostril_l_base" transform="matrix(1.15237,0.000527734,-0.000608997,1.32981,800.675,-268.105)">
|
||||
<path d="M564.004,297.352C571.731,297.355 578.003,300.27 578.001,303.857C577.999,307.445 571.724,310.355 563.997,310.352C556.27,310.348 549.999,307.433 550.001,303.846C550.003,300.258 556.278,297.348 564.004,297.352Z" style="fill:rgb(247,219,39);"/>
|
||||
</g>
|
||||
<g id="shadow_l" transform="matrix(0.465447,0.000213155,-0.00021318,0.465503,-174.253,3.49987)">
|
||||
<path d="M3456.32,281.418C3458.55,272.316 3473.1,265.286 3490.7,265.294C3509.83,265.303 3525.36,273.631 3525.35,283.88C3525.35,289.73 3520.28,294.95 3512.38,298.351C3512.57,297.556 3512.67,296.745 3512.67,295.922C3512.68,285.674 3497.15,277.346 3478.02,277.337C3469.81,277.333 3462.27,278.861 3456.32,281.418Z" style="fill:rgb(205,177,0);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="highlight11" serif:id="highlight1" transform="matrix(1.00155,-1.45487e-05,-1.45487e-05,1.00167,26.65,-13.0335)">
|
||||
<path d="M1505.26,121.885C1506.28,120.356 1512.93,125.765 1513.57,126.609C1514.35,127.654 1520.6,132.045 1517.75,134.502C1514.82,137.02 1513.11,131.001 1510.92,128.854C1508.92,126.891 1503.41,124.686 1505.26,121.885Z" style="fill:white;"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 124 KiB |