Show DescriptionDraws a full circle or partial arc centered at (x,y). The Returnsa Bezier object containing the arc TutorialExamplefill(.9) arc(125,125, 125) fill(.2) arc(40,40, 20) nofill() stroke(.2) arc(60,60, 40, range=180) arc(60,60, 30, range=90, ccw=True) stroke('red') arc(60,60, 20, range=270, close=True) image()Syntaximage(src, x, y, width=None, height=None, plot=True, **style) image(x, y, width=None, height=None, src="path-or-url", plot=True, **style) image(x, y, width=None, height=None, data="bytes-or-base64", plot=True, **style) DescriptionDraws an image to the screen, optionally scaling and compositing it in the process. The The As with other primitives, setting the Returnsan Image object that can be passed to background(), fill(), clip(), mask(), and plot() among others. Exampleimage("superfolia.jpg", 0, 0) line()Syntaxline(x1, y1, x2, y2, plot=True) DescriptionDraws a line-segment to the screen – a straight path between two points. The first pair of parameters sets the location of the ‘origin’ point and the following pair sets the location of the ‘destination’ point. You will only be able to see the line segment if the stroke() is different from the current background() color. Also note that lines will
not be drawn if the stroke() is set to Returnsa Bezier object containing the line TutorialExamplepen(2) stroke(0.2) line(10, 20, 80, 80) oval()Syntaxoval(x, y, width, height, plot=True, **style) DescriptionDraws an ellipse to the screen. The Returnsa Bezier object containing the oval TutorialExamplefill(0.2) oval(10,20, 40,40) poly()Syntaxpoly(self, x, y, radius, sides=4, points=None, plot=True, **style) DescriptionDraws an n-sided convex polygon (by default a square) centered at (x,y) and sized according to If you include a ReturnsBezier containing the rectangle TutorialExamplefill(.2) poly(30,30, 20) poly(80,30, 20, sides=5) poly(30,80, 20, sides=6) poly(80,80, 20, sides=8) fill(.2) poly(30,30, 20, points=5) poly(80,30, 20, points=6) poly(30,80, 20, points=8) poly(80,80, 20, points=12) rect()Syntaxrect(x, y, width, height, roundness=0.0, radius=None, plot=True, **style) DescriptionDraws a rectangle with a top-left corner of (x,y) and size of (width, height). The The Returnsa Bezier object containing the rectangle TutorialExamplefill(0.2) rect(10, 20, 60, 40) text()Syntaxtext(str, x, y, width=None, height=None, outline=False, plot=True, **options) Draw a string at x/y (while optionally setting its maximum width and height) text(x, y, width=None, height=None, str="", **options) The string can be omitted as the first arg if provided as a keyword argument text(x, y, width=None, height=None, xml="", **options) If an xml string is passed as a keyword argument, its tags will be accessible through the select() method and the tag names will be mapped to font definitions in the stylesheet() text(x, y, width=None, height=None, src="<path or url>", **options) Load the file pointed to by the src argument and draw its contents DescriptionDraws text to the screen, either as a single line or a multi-line block. The first parameter is a string of unicode text to display. The x & y parameters set the location of the text’s baseline. The optional Text will be
drawn using the current font() and layout() style, but individual settings can be overridden by passing new values as keyword arguments (the text() command supports all the same keyword arguments that font() and layout() provide). For instance, the text’s alignment can be set with the
layout() command or the optional Text will be drawn in the current fill() color, but will not reflect the global pen() and stroke() unless drawn as an By default, text is not outlined (which may not be what you want when exporting to PDF). To ‘trace’ the text into outlines, call text() with Inline Style MarkupBy default, text() will render the entire Note that for
PlotDevice to recognize your string as XML it must be passed as the The string you pass must be ‘valid’ XML, in particular you must escape the control characters:
When drawing an XML string, text() will ignore any tags that don’t correspond to a definition in the stylesheet(). Tags that don’t correspond to styles can still be useful though since their character location, layout, and attribute data can be retrieved from the TextMatch objects returned by Text.select(). Reading Text from Files and URLsIf you pass a Optional Parameters
You can override the current character-style for an individual text() invocation by including any of the keyword arguments supported by the font() command.
The current OpenType Feature settings from prior calls to the font() command may also be overridden for an individual text() call. Likewise, the current paragraph-style settings can be overridden for an individual text() invocation by including any of the layout arguments supported by layout().
If you have defined text styles using the
stylesheet() command, you can select one by passing a style-name as the
By default, the text() command will render to the canvas immediately. Passing Returnsthe Text object being drawn, or a Bezier path (if outlined) TutorialExamplefill(0.2) font("Helvetica", 20) text("hello", 10,50) text("goodbye", 10,70, italic=True) Legacy Commandsarrow()Syntaxarrow(x, y, width, type=NORMAL, plot=True, **style) DescriptionDraws
an arrow to the screen. The first two parameters set the location (measured from the arrow’s head), the third sets the width. Optionally you can define the arrow type with the fourth parameter. By default the arrow type is Returnsa Bezier object containing the arrow TutorialExamplefill(0.2) arrow(50, 50, 50) rotate(180) fill('red') arrow(50, 50, 50) star()Syntaxstar(x, y, points=20, outer=100, inner=50, plot=True, **style) DescriptionDraws a star to the screen. The If the inner radius is omitted, it will be set to half of the outer radius. Returnsa Bezier object containing the star PlotDevice EquivalentThe poly() command can draw either convex polygons or stars with regularized angles. When calling poly(), include a TutorialExamplefill(.75) star(50,50, 16, 50,25) fill(0.2) star(50,50, 8, 50) |