Cleanup: API docs (whitespace/line length)

This commit is contained in:
Campbell Barton 2016-06-12 10:05:35 +10:00
parent 1cd3676d4d
commit 2b15a588a1
5 changed files with 215 additions and 197 deletions

@ -12,53 +12,53 @@ This module holds key constants for the SCA_KeyboardSensor.
.. code-block:: python
# Set a connected keyboard sensor to accept F1
import bge
# Set a connected keyboard sensor to accept F1
import bge
co = bge.logic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.sensors["Keyboard"]
sensor.key = bge.events.F1KEY
co = bge.logic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.sensors["Keyboard"]
sensor.key = bge.events.F1KEY
.. code-block:: python
code-block:: python
# Do the all keys thing
import bge
# Do the all keys thing
import bge
co = bge.logic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.sensors["Keyboard"]
co = bge.logic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.sensors["Keyboard"]
for key,status in sensor.events:
# key[0] == bge.events.keycode, key[1] = status
if status == bge.logic.KX_INPUT_JUST_ACTIVATED:
if key == bge.events.WKEY:
# Activate Forward!
if key == bge.events.SKEY:
# Activate Backward!
if key == bge.events.AKEY:
# Activate Left!
if key == bge.events.DKEY:
# Activate Right!
for key,status in sensor.events:
# key[0] == bge.events.keycode, key[1] = status
if status == bge.logic.KX_INPUT_JUST_ACTIVATED:
if key == bge.events.WKEY:
# Activate Forward!
if key == bge.events.SKEY:
# Activate Backward!
if key == bge.events.AKEY:
# Activate Left!
if key == bge.events.DKEY:
# Activate Right!
.. code-block:: python
code-block:: python
# The all keys thing without a keyboard sensor (but you will
# need an always sensor with pulse mode on)
import bge
# The all keys thing without a keyboard sensor (but you will
# need an always sensor with pulse mode on)
import bge
# Just shortening names here
keyboard = bge.logic.keyboard
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
# Just shortening names here
keyboard = bge.logic.keyboard
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
if keyboard.events[bge.events.WKEY] == JUST_ACTIVATED:
print("Activate Forward!")
if keyboard.events[bge.events.SKEY] == JUST_ACTIVATED:
print("Activate Backward!")
if keyboard.events[bge.events.AKEY] == JUST_ACTIVATED:
print("Activate Left!")
if keyboard.events[bge.events.DKEY] == JUST_ACTIVATED:
print("Activate Right!")
if keyboard.events[bge.events.WKEY] == JUST_ACTIVATED:
print("Activate Forward!")
if keyboard.events[bge.events.SKEY] == JUST_ACTIVATED:
print("Activate Backward!")
if keyboard.events[bge.events.AKEY] == JUST_ACTIVATED:
print("Activate Left!")
if keyboard.events[bge.events.DKEY] == JUST_ACTIVATED:
print("Activate Right!")
*********

@ -8,13 +8,16 @@ Introduction
The bge.texture module allows you to manipulate textures during the game.
Several sources for texture are possible: video files, image files, video capture, memory buffer, camera render or a mix of that.
Several sources for texture are possible: video files, image files, video capture, memory buffer,
camera render or a mix of that.
The video and image files can be loaded from the internet using an URL instead of a file name.
In addition, you can apply filters on the images before sending them to the GPU, allowing video effect: blue screen, color band, gray, normal map.
In addition, you can apply filters on the images before sending them to the GPU, allowing video effect:
blue screen, color band, gray, normal map.
bge.texture uses FFmpeg to load images and videos. All the formats and codecs that FFmpeg supports are supported by this module, including but not limited to:
bge.texture uses FFmpeg to load images and videos.
All the formats and codecs that FFmpeg supports are supported by this module, including but not limited to:
* AVI
* Ogg
@ -58,6 +61,7 @@ When the texture object is deleted, the new texture is deleted and the old textu
.. literalinclude:: ../examples/bge.texture.2.py
:lines: 8-
*************
Video classes
*************
@ -196,6 +200,7 @@ Video classes
:return: see `FFmpeg Video and Image Status`_.
:rtype: int
*************
Image classes
*************
@ -336,7 +341,8 @@ Image classes
Update image buffer.
:arg imageBuffer: Buffer to load the new data from.
:type imageBuffer: :class:`~bgl.Buffer`, :class:`ImageBuff` or Python object implementing the buffer protocol (f.ex. bytes)
:type imageBuffer: :class:`~bgl.Buffer`, :class:`ImageBuff`
or Python object implementing the buffer protocol (f.ex. bytes)
:arg width: Width of the data to load.
:type width: int
:arg height: Height of the data to load.
@ -373,7 +379,8 @@ Image classes
:arg scene: Scene in which the image has to be taken.
:type scene: :class:`~bge.types.KX_Scene`
:arg observer: Reference object for the mirror (the object from which the mirror has to be looked at, for example a camera).
:arg observer: Reference object for the mirror
(the object from which the mirror has to be looked at, for example a camera).
:type observer: :class:`~bge.types.KX_GameObject`
:arg mirror: Object holding the mirror.
:type mirror: :class:`~bge.types.KX_GameObject`
@ -529,7 +536,8 @@ Image classes
.. method:: refresh(buffer=None, format="RGBA")
Refresh image - calculate and copy the image to an external buffer (optional) then invalidate its current content.
Refresh image - calculate and copy the image to an external buffer (optional)
then invalidate its current content.
:arg buffer: An optional object that implements the buffer protocol.
If specified, the image is calculated and copied to the buffer,
@ -803,13 +811,13 @@ Image classes
.. attribute:: depth
Use depth component of viewport as array of float - not suitable for texture source,
should only be used with bge.texture.imageToArray(mode='F').
should only be used with ``bge.texture.imageToArray(mode='F')``.
:type: bool
.. attribute:: zbuff
Use depth component of viewport as grey scale color - suitable for texture source.
Use depth component of viewport as grey scale color - suitable for texture source.
:type: bool
@ -991,6 +999,7 @@ Image classes
:return: True if the capture could be stopped, False otherwise.
:rtype: bool
***************
Texture classes
***************
@ -1024,16 +1033,16 @@ Texture classes
:type: bool
.. method:: refresh(refresh_source=True, ts=-1.0)
.. method:: refresh(refresh_source=True, timestamp=-1.0)
Refresh texture from source.
:arg refresh_source: Whether to also refresh the image source of the texture.
:type refresh_source: bool
:arg ts: If the texture controls a VideoFFmpeg object:
timestamp (in seconds from the start of the movie) of the frame to be loaded; this can be
used for video-sound synchonization by passing :attr:`~bge.types.KX_SoundActuator.time` to it. (optional)
:type ts: float
:arg timestamp: If the texture controls a VideoFFmpeg object:
timestamp (in seconds from the start of the movie) of the frame to be loaded; this can be
used for video-sound synchonization by passing :attr:`~bge.types.KX_SoundActuator.time` to it. (optional)
:type timestamp: float
.. attribute:: source
@ -1177,21 +1186,20 @@ Texture classes
Filter classes
**************
.. class:: FilterBGR24
Source filter BGR24.
.. class:: FilterBlueScreen
Filter for Blue Screen. The RGB channels of the color are left unchanged, while the output alpha is obtained as follows:
Filter for Blue Screen.
The RGB channels of the color are left unchanged, while the output alpha is obtained as follows:
* if the square of the euclidian distance between the RGB color and the filter's reference color is smaller than the filter's lower limit,
- if the square of the euclidian distance between the RGB color
and the filter's reference color is smaller than the filter's lower limit,
the output alpha is set to 0;
* if that square is bigger than the filter's upper limit, the output alpha is set to 255;
* otherwise the output alpha is linarly extrapoled between 0 and 255 in the interval of the limits.
- if that square is bigger than the filter's upper limit, the output alpha is set to 255;
- otherwise the output alpha is linarly extrapoled between 0 and 255 in the interval of the limits.
.. attribute:: color
@ -1224,7 +1232,8 @@ Filter classes
.. class:: FilterColor
Filter for color calculations. The output color is obtained by multiplying the reduced 4x4 matrix with the input color
Filter for color calculations.
The output color is obtained by multiplying the reduced 4x4 matrix with the input color
and adding the remaining column to the result.
.. attribute:: matrix
@ -1251,7 +1260,8 @@ Filter classes
.. class:: FilterGray
Filter for gray scale effect. Proportions of R, G and B contributions in the output gray scale are 28:151:77.
Filter for gray scale effect.
Proportions of R, G and B contributions in the output gray scale are 28:151:77.
.. attribute:: previous
@ -1370,22 +1380,26 @@ Functions
:arg mode: Optional argument representing the pixel format.
* You can use the characters R, G, B for the 3 color channels, A for the alpha channel,
- You can use the characters R, G, B for the 3 color channels, A for the alpha channel,
0 to force a fixed 0 color channel and 1 to force a fixed 255 color channel.
Examples:
* "BGR" will return 3 bytes per pixel with the Blue, Green and Red channels in that order.
* "RGB1" will return 4 bytes per pixel with the Red, Green, Blue channels in that order and the alpha channel forced to 255.
* A special mode "F" allows to return the image as an array of float. This mode should only be used to retrieve
the depth buffer of the class:`ImageViewport` and :class:`ImageRender` objects.
- "BGR" will return 3 bytes per pixel with the
Blue, Green and Red channels in that order.
- "RGB1" will return 4 bytes per pixel with the
Red, Green, Blue channels in that order and the alpha channel forced to 255.
- A special mode "F" allows to return the image as an array of float.
This mode should only be used to retrieve the depth buffer of the
class:`ImageViewport` and :class:`ImageRender` objects.
The default mode is "RGBA".
:type mode: str
:return: An object representing the image as one dimensional array of bytes of size (pixel_size*width*height),
line by line starting from the bottom of the image. The pixel size and format is determined by the mode
parameter. For mode 'F', the array is a one dimensional array of float of size (width*height).
line by line starting from the bottom of the image. The pixel size and format is determined by the mode
parameter. For mode 'F', the array is a one dimensional array of float of size (width*height).
:rtype: :class:`~bgl.Buffer`
.. function:: materialID(object, name)
@ -1400,7 +1414,8 @@ Functions
the texture by material. In that case the material must have a texture channel in first
position.
If the object has no material that matches name, it generates a runtime error. Use try/except to catch the exception.
If the object has no material that matches name, it generates a runtime error.
Use try/except to catch the exception.
Ex: ``bge.texture.materialID(obj, 'IMvideo.png')``

@ -27,8 +27,10 @@ base class --- :class:`PyObjectPlus`
:type: list of ints.
Each specifying the value of an axis between -1.0 and 1.0 depending on how far the axis is pushed, 0 for nothing.
The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
Each specifying the value of an axis between -1.0 and 1.0
depending on how far the axis is pushed, 0 for nothing.
The first 2 values are used by most joysticks and gamepads for directional control.
3rd and 4th values are only on some joysticks and can be used for arbitary controls.
* left:[-1.0, 0.0, ...]
* right:[1.0, 0.0, ...]

@ -1,7 +1,8 @@
..
This document is appended to the auto generated bmesh api doc to avoid clogging up the C files with details.
to test this run:
./blender.bin -b -noaudio -P doc/python_api/sphinx_doc_gen.py -- --partial bmesh* ; cd doc/python_api ; sphinx-build sphinx-in sphinx-out ; cd ../../
./blender.bin -b -noaudio -P doc/python_api/sphinx_doc_gen.py -- \
--partial bmesh* ; cd doc/python_api ; sphinx-build sphinx-in sphinx-out ; cd ../../
Submodules:
@ -59,9 +60,9 @@ There are 2 ways to access BMesh data, you can create a new BMesh by converting
:class:`bpy.types.BlendData.meshes` or by accessing the current edit mode mesh.
see: :class:`bmesh.types.BMesh.from_mesh` and :mod:`bmesh.from_edit_mesh` respectively.
When explicitly converting from mesh data python **owns** the data, that is to say - that the mesh only exists while
python holds a reference to it, and the script is responsible for putting it back into a mesh data-block when the edits
are done.
When explicitly converting from mesh data python **owns** the data, that is to say -
that the mesh only exists while python holds a reference to it,
and the script is responsible for putting it back into a mesh data-block when the edits are done.
Note that unlike :mod:`bpy`, a BMesh does not necessarily correspond to data in the currently open blend file,
a BMesh can be created, edited and freed without the user ever seeing or having access to it.

@ -151,7 +151,7 @@ Data Creation/Removal
^^^^^^^^^^^^^^^^^^^^^
Those of you familiar with other Python API's may be surprised that
new datablocks in the bpy API can't be created by calling the class:
new data-blocks in the bpy API can't be created by calling the class:
>>> bpy.types.Mesh()
Traceback (most recent call last):
@ -393,11 +393,11 @@ so these are accessed as normal Python types.
Internal Types
--------------
Used for Blender datablocks and collections: :class:`bpy.types.bpy_struct`
Used for Blender data-blocks and collections: :class:`bpy.types.bpy_struct`
For data that contains its own attributes groups/meshes/bones/scenes... etc.
There are 2 main types that wrap Blenders data, one for datablocks
There are 2 main types that wrap Blenders data, one for data-blocks
(known internally as ``bpy_struct``), another for properties.
>>> bpy.context.object