Home | Trees | Index | Help |
|
---|
Module pyemf :: Class EMF |
|
pyemf
for an
overview / mini tutorial.
Method Summary | |
---|---|
Creating Metafiles | |
Create an EMF structure in memory. | |
Boolean |
Read an existing EMF file. |
Boolean |
Write the EMF to disk. |
Drawing Parameters | |
int |
Retrieve the handle for a predefined graphics object. |
int |
Make the given graphics object current. |
int |
Delete the given graphics object. |
int |
Create a pen, used to draw lines and path outlines. |
int |
Create a solid brush used to fill polygons. |
int |
Create a hatched brush used to fill polygons. |
int |
Set the background color used for any transparent regions in fills or hatched brushes. |
int |
Set the background mode for interaction between transparent areas in the region to be drawn and the existing background. |
int |
Set the polygon fill mode. |
Drawing Primitives | |
Set the pixel to the given color. | |
int |
Draw a sequence of connected lines. |
int |
Draw multiple polylines. |
int |
Draw a closed figure bounded by straight line segments. |
int |
Draw multiple polygons. |
int |
Draw a rectangle using the current pen. |
int |
Draw a rectangle with rounded corners using the current pen. |
int |
Draw an ellipse using the current pen. |
int |
Draw an arc of an ellipse. |
int |
Draw a chord of an ellipse. |
int |
Draw a pie slice of an ellipse. |
int |
Draw cubic Bezier curves using the list of points as both endpoints and control points. |
Path Primatives | |
int |
Begin defining a path. |
int |
End the path definition. |
int |
Move the current point to the given position and implicitly begin a new figure or path. |
int |
Draw a straight line using the current pen from the current point to the given position. |
int |
Draw a sequence of connected lines starting from the current position and update the position to the final point in the list. |
int |
Draw an arc and update the current position. |
int |
Draw cubic Bezier curves, as described in PolyBezier , but in addition draw a line
from the previous position to the start of the curve. |
int |
Close a currently open path, which connects the current position to the starting position of a figure. |
int |
Close any currently open path and fills it using the currently selected brush and polygon fill mode. |
int |
Close any currently open path and outlines it using the currently selected pen. |
int |
Close any currently open path, outlines it using the currently selected pen, and fills it using the current brush. |
Clipping | |
int |
Use the current path as the clipping path. |
Text | |
int |
Create a new font object. |
int |
Set the subsequent alignment of drawn text. |
int |
Set the text foreground color. |
int |
Draw a string of text at the given position using the current FONT and other text attributes. |
Coordinate System Transformation | |
int |
Saves the current state of the graphics mode (such as line and fill styles, font, clipping path, drawing mode and any transformations) to a stack. |
int |
Restores the state of the graphics mode to a stack. |
boolean |
Set the world coordinate to logical coordinate linear transform for subsequent operations. |
boolean |
Change the current linear transform. |
**Experimental** -- Viewport Manipulation | |
int |
Set the window mapping mode. |
2-tuple (x,y) if successful, or None if unsuccessful |
Set the origin of the viewport, which translates the origin of the coordinate system by (xv,yv). |
2-tuple (x,y) |
Get the origin of the viewport. |
2-tuple (x,y) if successful, or None if unsuccessful |
Set the origin of the window, which translates the origin of the coordinate system by (-xw,-yw). |
2-tuple (x,y) |
Get the origin of the window. |
2-tuple (width,height) if successful, or None if unsuccessful |
Set the dimensions of the viewport in device units. |
2-tuple (width,height) if successful, or None if unsuccessful |
Scale the dimensions of the viewport. |
2-tuple (width,height) |
Get the dimensions of the viewport in device units (i.e. |
2-tuple (width,height) if successful, or None if unsuccessful |
Set the dimensions of the window. |
2-tuple (width,height) if successful, or None if unsuccessful |
Scale the dimensions of the window. |
2-tuple (width,height) |
Get the dimensions of the window in logical units (integer numbers of pixels). |
Method Details |
---|
__init__(self,
width=6.0,
height=4.0,
density=300,
units='in',
description='pyemf.sf.net',
verbose=False)
Create an EMF structure in memory. The size of the resulting image
is specified in either inches or millimeters depending on the value of
|
load(self, filename=None)Read an existing EMF file. If any records exist in the current object, they will be overwritten by the records from this file.
|
save(self, filename=None)Write the EMF to disk.
|
GetStockObject(self, obj)Retrieve the handle for a predefined graphics object. Stock objects include (at least) the following:
|
SelectObject(self, handle)Make the given graphics object current.
|
DeleteObject(self, handle)Delete the given graphics object. Note that, now, only those contexts into which the object has been selected get a delete object records.
|
CreatePen(self, style, width, color)Create a pen, used to draw lines and path outlines.
|
CreateSolidBrush(self, color)Create a solid brush used to fill polygons.
|
CreateHatchBrush(self, hatch, color)Create a hatched brush used to fill polygons. Note: Currently appears unsupported in OpenOffice.
|
SetBkColor(self, color)Set the background color used for any transparent regions in fills or hatched brushes. Note: Currently appears sporadically supported in OpenOffice. |
SetBkMode(self, mode)Set the background mode for interaction between transparent areas in the region to be drawn and the existing background. The choices for mode are:
|
SetPolyFillMode(self, mode)Set the polygon fill mode. Generally these modes produce different results only when the edges of the polygons overlap other edges.
|
SetPixel(self, x, y, color)Set the pixel to the given color.
|
Polyline(self, points)Draw a sequence of connected lines.
|
PolyPolyline(self, polylines)Draw multiple polylines. The polylines argument is a list of lists, where each inner list represents a single polyline. Each polyline is described by a list of x,y tuples as inPolyline . For example:
lines=[[(100,100),(200,100)], [(300,100),(400,100)]] emf.PolyPolyline(lines)draws two lines, one from 100,100 to 200,100, and another from 300,100 to 400,100.
|
Polygon(self, points)Draw a closed figure bounded by straight line segments. A polygon is defined by a list of points that define the endpoints for a series of connected straight line segments. The end of the last line segment is automatically connected to the beginning of the first line segment, the border is drawn with the current pen, and the interior is filled with the current brush. SeeSetPolyFillMode for the fill effects when
an overlapping polygon is defined.
|
PolyPolygon(self, polygons)Draw multiple polygons. The polygons argument is a list of lists, where each inner list represents a single polygon. Each polygon is described by a list of x,y tuples as inPolygon . For example:
lines=[[(100,100),(200,100),(200,200),(100,200)], [(300,100),(400,100),(400,200),(300,200)]] emf.PolyPolygon(lines) draws two squares. Note: Currently partially supported in OpenOffice. The line width is ignored and the polygon border is not closed (the final point is not connected to the starting point in each polygon).
|
Rectangle(self, left, top, right, bottom)Draw a rectangle using the current pen.
|
RoundRect(self, left, top, right, bottom, cornerwidth, cornerheight)Draw a rectangle with rounded corners using the current pen.
|
Ellipse(self, left, top, right, bottom)Draw an ellipse using the current pen.
|
Arc(self, left, top, right, bottom, xstart, ystart, xend, yend)Draw an arc of an ellipse. The ellipse is specified by its bounding rectange and two lines from its center to indicate the start and end angles. left, top, right, bottom describe the bounding rectangle of the ellipse. The start point given by xstart,ystert defines a ray from the center of the ellipse through the point and out to infinity. The point at which this ray intersects the ellipse is the starting point of the arc. Similarly, the infinite radial ray from the center through the end point defines the end point of the ellipse. The arc is drawn in a counterclockwise direction, and if the start and end rays are coincident, a complete ellipse is drawn.
|
Chord(self, left, top, right, bottom, xstart, ystart, xend, yend)Draw a chord of an ellipse. A chord is a closed region bounded by an arc and the [straight] line between the two points that define the arc start and end. The arc start and end points are defined as inArc .
|
Pie(self, left, top, right, bottom, xstart, ystart, xend, yend)Draw a pie slice of an ellipse. The ellipse is specified as inArc , and
it is filled with the current brush.
|
PolyBezier(self, points)Draw cubic Bezier curves using the list of points as both endpoints and control points. The first point is used as the starting point, the second and thrird points are control points, and the fourth point is the end point of the first curve. Subsequent curves need three points each: two control points and an end point, as the ending point of the previous curve is used as the starting point for the next curve.
|
BeginPath(self)Begin defining a path. Any previous unclosed paths are discarded.
|
EndPath(self)End the path definition.
|
MoveTo(self, x, y)Move the current point to the given position and implicitly begin a new figure or path.
|
LineTo(self, x, y)Draw a straight line using the current pen from the current point to the given position.
|
PolylineTo(self, points)Draw a sequence of connected lines starting from the current position and update the position to the final point in the list.
|
ArcTo(self, left, top, right, bottom, xstart, ystart, xend, yend)Draw an arc and update the current position. The arc is drawn as
described in
|
PolyBezierTo(self, points)Draw cubic Bezier curves, as described inPolyBezier , but in addition draw a line
from the previous position to the start of the curve. If the arc is
successfully rendered, the current position is updated so that
subsequent path operations such as LineTo , PolylineTo , etc. will follow from the end
of the curve.
|
CloseFigure(self)Close a currently open path, which connects the current position to the starting position of a figure. Usually the starting position is the most recent call toMoveTo after BeginPath .
|
FillPath(self)Close any currently open path and fills it using the currently selected brush and polygon fill mode.
|
StrokePath(self)Close any currently open path and outlines it using the currently selected pen.
|
StrokeAndFillPath(self)Close any currently open path, outlines it using the currently
selected pen, and fills it using the current brush. Same as stroking
and filling using both the
|
SelectClipPath(self, mode=5)Use the current path as the clipping path. The current path must be
a closed path (i.e. with
|
CreateFont(self, height, width=0, escapement=0, orientation=0, weight=400, italic=0, underline=0, strike_out=0, charset=0, out_precision=0, clip_precision=0, quality=0, pitch_family='DEFAULT_PITCH|FF_DONTCARE', name='Times New Roman')Create a new font object. Presumably, when rendering the EMF the system tries to find a reasonable approximation to all the requested attributes.
|
SetTextAlign(self, alignment)Set the subsequent alignment of drawn text. You can also pass a flag indicating whether or not to update the current point to the end of the text. Alignment may have the (sum of) values:
|
SetTextColor(self, color)Set the text foreground color. |
TextOut(self, x, y, text)Draw a string of text at the given position using the current FONT and other text attributes.
|
SaveDC(self)Saves the current state of the graphics mode (such as line and fill
styles, font, clipping path, drawing mode and any transformations) to a
stack. This state can be restored by
|
RestoreDC(self, stackid)Restores the state of the graphics mode to a stack. The Note: If the retrieved state is not at the top of the stack, any saved states above it are thrown away. Note: Currently unsupported in OpenOffice -- it apparently uses the bounding rectangle of the path as the clip area, not the path itself.
|
SetWorldTransform(self, m11=1.0, m12=0.0, m21=0.0, m22=1.0, dx=0.0, dy=0.0)Set the world coordinate to logical coordinate linear transform for subsequent operations. With this matrix operation, you can translate, rotate, scale, shear, or a combination of all four. The matrix operation is defined as follows where (x,y) are the original coordinates and (x',y') are the transformed coordinates:| x | | m11 m12 0 | | x' | | y | * | m21 m22 0 | = | y' | | 0 | | dx dy 1 | | 0 |or, the same thing defined as a system of linear equations: x' = x*m11 + y*m21 + dx y' = x*m12 + y*m22 + dy http://msdn.microsoft.com/library/en-us/gdi/cordspac_0inn.asp says that the offsets are in device coordinates, not pixel coordinates. Note: Currently partially supported in OpenOffice.
|
ModifyWorldTransform(self, mode, m11=1.0, m12=0.0, m21=0.0, m22=1.0, dx=0.0, dy=0.0)Change the current linear transform. SeeSetWorldTransform for a description of
the matrix parameters. The new transform may be modified in one of
three ways, set by the mode parameter:
The reason that there are two different multiplication types is that matrix multiplication is not commutative, which means the order of multiplication makes a difference. Note: The parameter order was changed from GDI standard so that I could make the matrix parameters optional in the case of MWT_IDENTITY. Note: Currently appears unsupported in OpenOffice.
|
SetMapMode(self, mode)Set the window mapping mode. This is the mapping between pixels in page space to pixels in device space. Page space is the coordinate system that is used for all the drawing commands -- it is how pixels are identified and figures are placed in the metafile. They are integer units. Device space is the coordinate system of the final output, measured in physical dimensions such as mm, inches, or twips. It is this coordinate system that provides the scaling that makes metafiles into a scalable graphics format.
|
SetViewportOrgEx(self, xv, yv)Set the origin of the viewport, which translates the origin of the coordinate system by (xv,yv). A pixel drawn at (x,y) in the new coordinate system will be displayed at (x+xv,y+yv) in terms of the previous coordinate system. Contrast this withSetWindowOrgEx , which seems to be the
opposite translation. So, if in addition, the window origin is set to
(xw,yw) using SetWindowOrgEx , a pixel drawn at (x,y)
will be displayed at (x-xw+xv,y-yw+yv) in terms of the original
coordinate system.
|
GetViewportOrgEx(self)Get the origin of the viewport.
|
SetWindowOrgEx(self, xw, yw)Set the origin of the window, which translates the origin of the coordinate system by (-xw,-yw). A pixel drawn at (x,y) in the new coordinate system will be displayed at (x-xw,y-yw) in terms of the previous coordinate system. Contrast this withSetViewportOrgEx , which seems to be the
opposite translation. So, if in addition, the viewport origin is set to
(xv,yv) using SetViewportOrgEx , a pixel drawn at (x,y)
will be displayed at (x-xw+xv,y-yw+yv) in terms of the original
coordinate system.
|
GetWindowOrgEx(self)Get the origin of the window.
|
SetViewportExtEx(self, x, y)Set the dimensions of the viewport in device units. Device units are physical dimensions, in millimeters. The total extent is equal to the width is millimeters multiplied by the density of pixels per millimeter in that dimension. Note: this is only usable whenSetMapMode has been set to MM_ISOTROPIC
or MM_ANISOTROPIC.
|
ScaleViewportExtEx(self, x_num, x_den, y_num, y_den)Scale the dimensions of the viewport.
|
GetViewportExtEx(self)Get the dimensions of the viewport in device units (i.e. physical dimensions).
|
SetWindowExtEx(self, x, y)Set the dimensions of the window. Window size is measured in integer numbers of pixels (logical units). Note: this is only usable whenSetMapMode has been set to MM_ISOTROPIC
or MM_ANISOTROPIC.
|
ScaleWindowExtEx(self, x_num, x_den, y_num, y_den)Scale the dimensions of the window.
|
GetWindowExtEx(self)Get the dimensions of the window in logical units (integer numbers of pixels).
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Sun Jan 1 09:25:22 2006 | http://epydoc.sf.net |