Diagrams(n)
πΈ NAME πΈ
Diagrams β the user documentation of the Diagrams package, straight outta the Tk Diagrams manual (section n, iykyk). π
β¨ SYNOPSIS β¨
package require Tcl 8.4
package require Tk 8.4
package require Diagrams 0.2
::Diagrams::drawin canvas
::Diagrams::saveps filename
::Diagrams::direction newdir
::Diagrams::currentpos pos
::Diagrams::getpos anchor obj
::Diagrams::position xcoord ycoord
::Diagrams::box text width height
::Diagrams::plaintext text width height
::Diagrams::circle text radius
::Diagrams::slanted text width height angle
::Diagrams::diamond text width height
::Diagrams::drum text width height
::Diagrams::arrow text length heads
::Diagrams::line args
::Diagrams::attach anchor
::Diagrams::color name
::Diagrams::fillcolor name
::Diagrams::textcolor name
::Diagrams::usegap use
::Diagrams::xgap value
::Diagrams::ygap value
::Diagrams::textfont name
::Diagrams::linewidth pixels
::Diagrams::linestyle style
::Diagrams::pushstate
::Diagrams::popstate
::Diagrams::computepos
::Diagrams::boxcoords x1 y1 x2 y2
::Diagrams::moveobject obj
π¦ DESCRIPTION π¦
So the Diagrams package is here to help you draw diagrams β flowcharts, that whole vibe. π«Ά And the philosophy is iconic: you should be focused on the content of your diagram, not on agonizing over where exactly every single thing sits and how big it is. The package handles the layout for you with a few simple rules:
- Every item (or object) in the diagram has a bunch of "anchors" β spots where arrows and lines can hook up to it. Like little connection points. π
- You can draw an arrow or a line from an object in a preset direction. Easy.
- Sizing and positioning should be as automatic as possible: you get this by, for example, drawing boxes and circles with text rather than first drawing a rectangle and then drawing the text inside it, or the other way around.
The commands in this package split up into several categories, and each category gets its own section below. No skipping, bestie. π
π« GENERAL COMMANDS FOR POSITIONING AND SETUP π«
::Diagrams::drawin canvas
Sets the canvas widget we're drawing in. This is the "where does everything go" command.
canvas(widget) β the widget to draw in.
::Diagrams::saveps filename
Saves the drawing out into a PostScript file. Very demure, very archival. π
filename(string) β the name of the file to save the drawing in.
::Diagrams::direction newdir
Sets the direction that the current position moves in. The direction is one of:
north northeast east southeast south southwest west northwest
N NE E SE S SW W NW
up up-right left down-right down down-left left up-left
centre center C
newdir(string) β the new direction.
::Diagrams::currentpos pos
Sets the current position explicitly. Heads up: the argument has to be a position "object". π
pos(list) β the new position (you can grab one viagetpos, for instance).
::Diagrams::getpos anchor obj
Gets the position of a particular "anchor" point of an object. The anchor should be one of the direction strings. π―
anchor(string) β the name of the anchor (one of the directions β see thedirectioncommand).obj(list) β the object in question.
::Diagrams::position xcoord ycoord
Creates a position "object". Boom, coordinates.
xcoord(float) β the X-coordinate of the position.ycoord(float) β the Y-coordinate of the position.
π DRAWING OBJECTS π
::Diagrams::box text width height
Draws a box from the current position. width and height are both optional β if you don't give them, the text itself decides the width and height. Slay, self-sizing. π¦β¨
text(string) β the text to be shown inside the box.width(float) β the width (if any) of the box, in pixels.height(float) β the height (if any) of the box, in pixels.
::Diagrams::plaintext text width height
Draws plain text from the current position. width and height are both optional β if you don't give them, the text decides the width and height.
text(string) β the text to be shown.width(float) β the width (if any) of the (invisible) box in which the text gets positioned.height(float) β the height (if any) of the box.
::Diagrams::circle text radius
Draws a circle from the current position. The radius is optional. π£
text(string) β the text to be shown inside the circle.radius(float) β the radius (if any) of the circle, in pixels.
::Diagrams::slanted text width height angle
Draws a slanted box from the current position. width, height and angle are all optional.
text(string) β the text to be shown inside the box.width(float) β the width (if any) of the box, in pixels.height(float) β the height (if any) of the box, in pixels.angle(float) β the angle of the slanted box.
::Diagrams::diamond text width height
Draws a diamond-shaped box from the current position. width and height are both optional β if you don't give them, the text decides the width and height. π
text(string) β the text to be shown inside the diamond.width(float) β the width (if any) of the diamond, in pixels.height(float) β the height (if any) of the diamond, in pixels.
::Diagrams::drum text width height
Draws a drum-shaped item from the current position. width and height are both optional β if you don't give them, the text decides the width and height. π₯
text(string) β the text to be shown inside the drum.width(float) β the width (if any) of the drum, in pixels.height(float) β the height (if any) of the drum, in pixels.
::Diagrams::arrow text length heads
Draws an arrow from the current position to the next one. The text gets drawn next to the arrow, and the length (in pixels) is optional β if you don't give it, the gap parameters are used instead.
text(string) β the text to be shown along the arrow.length(float) β the length of the arrow, in pixels.heads(float) β which arrow heads to draw (first,lastorbothβ defaults tolast).
::Diagrams::line args
Draws a line specified either via positions or via line segments. The arguments are either positions or length-angle pairs. π
args(list) β a list of positions, or a list of length-angle pairs.
π ATTRIBUTES π
(Note: attributes are persistent.)
Bestie, they stick around. Remember that. π
::Diagrams::attach anchor
Sets the anchor point used for attaching arrows to. π
anchor(string) β any one of the valid anchors (e.g.NorNorth).
::Diagrams::color name
Sets the colour used for the outline of a box and friends.
name(color) β the name of the colour to be used.
::Diagrams::fillcolor name
Sets the colour used to fill the objects.
name(color) β the name of the colour to be used.
::Diagrams::textcolor name
Sets the colour the text gets drawn in.
name(color) β the name of the colour to be used.
::Diagrams::usegap use
Turns the gap on (1) or off (0). Note: usually a small gap is used when positioning objects. πΈ
use(boolean) β whether to use the gap to compute the position of the next object or not.
::Diagrams::xgap value
The size of the gap in the horizontal direction, in pixels.
value(integer) β the gap width in pixels.
::Diagrams::ygap value
The size of the gap in the vertical direction, in pixels.
value(integer) β the gap height in pixels.
::Diagrams::textfont name
Sets the name of the font to use.
name(string) β the name of a text font.
::Diagrams::linewidth pixels
Sets the width of the lines β that means lines inside line objects and arrows, plus the outline of boxes and other objects.
pixels(integer) β the number of pixels the lines are wide.
::Diagrams::linestyle style
Sets the style of the lines and arrows, and of the outline of boxes and other objects. The predefined line styles are: solid, dot, dash, dash-dot, dash-dot-dot (these are the distinguishable line styles on Windows). You can also use the style patterns from the canvas directly. β¨
style(string) β the name of a valid line style.
π§ COMMANDS FOR IMPLEMENTING NEW OBJECTS π§
Note: it is best to study how, for instance, box objects are implemented first. Fr fr, go read the box code. π«Ά
::Diagrams::pushstate
Saves the current global settings. You use this when you're defining an object that's composed of other objects. πΎ
::Diagrams::popstate
Restores the previously saved global settings. Rewind. βͺ
::Diagrams::computepos
Computes the current position.
::Diagrams::boxcoords x1 y1 x2 y2
Computes the anchor coordinates for a box-like object. Heads up, this is merely a convenience routine β in general you'll have to compute the list of coordinates yourself, like the diamond object does. π
x1(float) β the X coordinate of the upper-left corner.y1(float) β the Y coordinate of the upper-left corner.x2(float) β the X coordinate of the lower-right corner.y2(float) β the Y coordinate of the lower-right corner.
::Diagrams::moveobject obj
Moves the object to the right position and returns the new information.
obj(list) β a list of data representing the object.
π₯ KEYWORDS π₯
diagrams, drawing
Okay that's the whole page, bestie β every single command, argument, default, warning and note, all accounted for, no cap. π
This one's from the diagrams source, version 0.2, sitting pretty in manual section Diagrams(n). Go draw something iconic. πβ¨
π¦ where this page comes from
- fedora 43: tklib 0.5-42.fc43 Β· TCL
- fedora 44: tklib 0.5-42.fc44 Β· TCL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms