Matplotlib
Implementation notes
The matplotlib implementation is only a partial implementation because of several limitations:
-
Depth buffer: matplotlib does not have a proper depth buffer that allows to test individual pixels. This means points/lines/triangles need to be sorted in order to draw them from back to front. Most of the time, this does the trick but there exist some situations where it is impossible to avoid problems. For example, consider two triangles that intersect each other. In in such a case, we have to decide arbitrarily which triangle will be drawn on top of the other.
-
Trilinear interpolation: there is no easy (nor fast) way to interpolate a color inside a triangle and this limits the kind of shading we can use. Namely, we can have flat shading (per face) but not Gouraud (per vertex) nor Phong (per pixel).
The matplotlib implementation relies a lot on numpy arrays because they're compatible with the Data/Buffer approach. However, this is only a design choice and it is possible to use other approaches. The only difficulty is to control memory usage such as not to make too many copies of buffer.
Status
Core
- core.Data - encapsulate raw data (any type)
- core.Buffer - a structured view on raw data
- core.Canvas - create a drawing surface
- core.Viewport - define a region over a drawing surface
- core.Texture - define a 1D, 2D or 3D Buffer
- core.Measure - define a value with unit
- core.Color - define a color
- core.Marker - define a marker type
Visual
Zero dimension
- visual.Pixels - create a collection of pixels
- visual.Points - create a collection of points
- visual.Markers - create a collection of markers
One dimension
- visual.Segments - create a collection of line segments
- visual.Lines - create a collection of straight lines
- visual.Paths - create a collection of smooth lines
Two dimensions
- visual.Triangles - create a collection of triangles
- visual.Polygons - create a collection of polygons
- visual.Glyphs - create a collection of glyphs
Three dimensions
- visual.Mesh - create a mesh
- visual.Volume - create a volume
Transform
Base
- transform.Transform - Generic transform
Colors
- transform.Colormap - map a scalar to a color (
T[1] → T[4]
) - transform.Light - modify a color according to a light (
T[n,3] → T[n,4]
)
Operators (T[n] × T[n] → T[n]
)
- transform.Add - Addition
- transform.Sub - Subtraction
- transform.Mul - Multiplication
- transform.Div - Division
Accessors (T[n] → T[1]
)
- transform.X / transform.R - First component
- transform.Y / transform.G - Second component
- transform.Z / transform.B - Third component
- transform.W / transform.A - Fourth component
- transform.Join - join several transforms (
T[1] × … × T[1] → T[n]
)
Geometry (T[n] → T[n]
)
- transform.Scale - Arbitrary scaling
- transform.Translate - Arbitraty translation
- transform.Rotate - Arbitraty rotation
- transform.MVP - Model / View / Projection (
T[n] → T[3]
)
Screen (JIT) (∅ → T[1]
)
- transform.Screen - Screen coordinates
- transform.ScreenX - Screen X coordinates
- transform.ScreenY - Screen Y coordinates
- transform.ScreenZ - Screen Z coordinates
Measure (T[n] → T[n]
)
- transform.Pixel - Conversion to pixel
- transform.Point - Conversion to point (1/72 inch)
- transform.Inch - Conversion to inch
- transform.Millimeter - Conversion to millimeter
- transform.Centimeter - Conversion to centimeter
- transform.Meter - Conversion to meter
- transform.Kilometer - Conversion to kilometer