The renderer is responsible for building the primitives, and complex objects to be drawn by pyglet. This module also contains various base classes for primitives which can be modified on the fly.
This is the base class for any primitive to draw to the screen. To be used most effectively, all library-provided primitives should be declared within renderer.Renderer.
| Parameters: | renderer (renderer.Renderer) – renderer instance to add this primitive to. |
|---|---|
| Raises : | AttributeError if renderer is not passed to constructor and not instantiated from an instance of a renderer |
This class allows access to the primitives (the basic drawing building blocks) to draw just about anything. Widgets should use these to draw themselves:
class Button(RectWidget):
def __init__(self, renderer, x, y, width, height, text):
btn_base = renderer.Rectangle(x, y, width, height,
color=(0.2, 0.3, 0.2))
btn_text = renderer.Text(x, y, width, height, text)
# etc.
# etc.
primitives should be called through the Renderer instance instead of through the class (i.e.):
renderer = Renderer()
renderer.Rectangle()
instead of:
renderer = Renderer()
Renderer.Rectangle(renderer=renderer)
There is special python magic to make that work. See __init__() for that.
This class creates a rectangle primitive.
| Parameters: |
|
|---|
This move method actually modifies the vertex lists to update the positions of the polygons. This is most efficient when in unit-mode where only one unit is moving at a time.
This is because at this point very few objects are moving per frame. So all objects that have not moved take up zero cpu time.
This may not be as efficient when applied to normal, condensed, or liquid mode because far more polygons will be moving at the same time. It may be better to draw each vertex list separately after having gone through a matrix transformation.
As a final note, it may be best to move these primitives into a class built in cython so that python doesn’t have to deal with all this bullshit processing.
| Parameters: |
|
|---|