Grease logo

Previous topic

grease.mode – Modal Framework

Next topic

grease.world – Entity Environment

This Page

grease.renderer – World Presentation

Renderers define world presentation. This module contains the built-in renderer classes.

See also:

class grease.renderer.Vector(scale=1.0, line_width=None, anti_alias=True, corner_fill=True, position_component='position', renderable_component='renderable', shape_component='shape')

Renders shapes in a classic vector graphics style

Parameters:
  • scale – Scaling factor applied to shape vertices when rendered.
  • line_width – The line width provided to glLineWidth before rendering. If not specified or None, glLineWidth is not called, and the line width used is determined by the OpenGL state at the time of rendering.
  • anti_alias – If True, OpenGL blending and line smoothing is enabled. This allows for fractional line widths as well. If False, the blending and line smoothing modes are unchanged.
  • corner_fill – If true (the default), the shape corners will be filled with round points when the line_width exceeds 2.0. This improves the visual quality of the rendering at larger line widths at some cost to performance. Has no effect if line_width is not specified.
  • position_component – Name of grease.component.Position component to use. Shapes rendered are offset by the entity positions.
  • renderable_component – Name of grease.component.Renderable component to use. This component specifies the entities to be rendered and their base color.
  • shape_component – Name of grease.component.Shape component to use. Source of the shape vertices for each entity.

The entities rendered are taken from the intersection of he position, renderable and shape components each time draw() is called.

class grease.renderer.Camera(position=None, angle=None, zoom=None, relative=False)

Sets the point of view for further renderers by altering the model/view matrix when it is drawn. It does not actually perform any drawing itself.

Parameters:
  • position (Vec2d) – The position vector for the camera. Sets the center of the view.
  • angle (float) – Camera rotation in degrees about the z-axis.
  • zoom (Vec2d) – Scaling vector for the coordinate axis.
  • relative – Flag to indicate if the camera settings are relative to the previous view state. If False the view state is reset before setting the camera view by loading the identity model/view matrix.

At runtime the camera may be manipulated via attributes with the same names and functions as the parameters above.