Node:Clipping,
Next:Redirecting output,
Previous:canvas,
Up:Tricks
Clipping
A rectangle, polygon, or ellipsis can be used to define a clipping
region. Any drawing commands (see canvas) issued afterwards are
confined in the region. You can even nest multiple clipping regions,
in which case, drawings will be clipped to the intersection of the
regions. canvas.endclip()
ends the clipping. Clipping commands
and endclip()
must nest properly.
from pychart import *
data = [(10, 20), (20, 65), (30, 55), (40, 45)]
# tic_angle is the angle X values are displayed below the axis.
xaxis = axis.X(label="Stuff")
yaxis = axis.Y(label="Value")
ar = area.T(x_axis=xaxis, y_axis=yaxis)
plot = line_plot.T(label="foo", data=data, xcol=0, ycol=1,
tick_mark=tick_mark.star)
ar.add_plot(plot)
canvas.ellipsis(line_style.T(width=1.5,dash=(4,4)), None, 30, 20, 80, 0.8)
canvas.clip_ellipsis(30, 20, 80, 0.8)
ar.draw()
canvas.endclip()
canvas.clip X1, Y1, X2, Y2,
|
Function |
Activate a rectangular clip region, (X1, Y1) - (X2, Y2).
You must call endclip() after you completed drawing.
canvas.clip(x,y,x2,y2)
draw something ...
canvas.endclip()
|
canvas.clip_ellipsis X, Y, RADIUS, Y_ELONGATION
|
Function |
Draw an ellipsis with line_style and fill PATTERN. The center is (X, Y), X radius is RADIUS, and Y radius is RADIUS*RATIO, whose default value is 1.0. SHADOW is either None or a tuple (XDELTA,
YDELTA, fillstyle). If non-null, a shadow of FILLSTYLE is drawn
beneath the polygon at the offset of (XDELTA, YDELTA).
|
canvas.clip_polygon [(X1,Y2),(X2,Y2), ..., (Xn, Yn)]
|
Function |
Create a polygon clip region. You must call endclip() after
you completed drawing. See also the polygon method.
|