-
Notifications
You must be signed in to change notification settings - Fork 10
DefCanvas
Jim Pivarski edited this page Mar 15, 2015
·
1 revision
- summary Create a top-level <svg /> object, which defines the aspect ratio for the whole image
- labels Reference,Version1
_(This page applies only to the 1.x branch of SVGFig.)_
Creates a top-level [ClassSVG SVG] object, allowing the user to control the image size and aspect ratio.
- canvas(sub, sub, sub..., attribute=value)*
sub | _optional list_ | nested SVG elements or text/Unicode | ||||
attribute=value pairs | _optional keywords_ | SVG attributes, such as width="400px", viewBox="0 0 100 100" |
width | "400px" | |||
height | "400px" | |||
viewBox | "0 0 100 100" | |||
xmlns | "http://www.w3.org/2000/svg" | |||
xmlns:xlink | "http://www.w3.org/1999/xlink" | |||
version | "1.1" | |||
style | "stroke:black; fill:none; stroke-width:0.5pt; stroke-linejoin:round; text-anchor:middle" | |||
font-family | "Helvetica,Arial,!FreeSans,Sans,sans,sans-serif" |
You can change the defaults through the canvas_defaults variable. For example,
>>> import svgfig >>> svgfig.canvas().attr["font-family"] 'font-famica,Arial,FreeSans,Sans,sans,sans-serif' >>> svgfig.canvas_defaults["font-family"] = "serif" >>> svgfig.canvas().attr["font-family"] 'serif'
Creates a top-level [ClassSVG SVG] object with the same arguments, but draws an outline around the viewBox and fills the background with "cornsilk" (yellowish) to make it easier to find.
Use this to optimize the box outline, then drop the "outline" for a normal canvas.
>>> canvas_outline(...) >>> # I like it >>> canvas(...)