Node:Clipping,
Previous:Drawing objects,
Up:canvas
Clipping
A rectangle, polygon, or ellipsis can be used to define a clipping
region. Any drawing commands (see canvas) issued afterward 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.
Clipping test
Below is the source code that produces the above chart.
../demos/cliptest.py
from pychart import *
can = canvas.default_canvas()
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)
can.ellipsis(line_style.T(width=1.5,dash=(4,4)), None, 30, 20, 80, 0.8)
can.clip_ellipsis(30, 20, 80, 0.8)
ar.draw(can)
can.endclip()
canvas.T:clip X1, Y1, X2, Y2
|
Method |
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 X1, Y1, X2, Y2
|
Function |
Calls the method with the same name on the default canvas object.
|
canvas.T:clip_ellipsis X, Y, RADIUS, Y_ELONGATION
|
Method |
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_ellipsis X, Y, RADIUS, Y_ELONGATION
|
Function |
Calls the method with the same name on the default canvas object.
|
canvas.T:clip_polygon [(X1,Y2),(X2,Y2), ..., (Xn, Yn)]
|
Method |
Create a polygon clip region. You must call endclip() after
you completed drawing. See also the polygon method.
|
canvas.clip_polygon [(X1,Y2),(X2,Y2), ..., (Xn, Yn)]
|
Function |
Calls the method with the same name on the default canvas object.
|