Tk_GetDash(3tk)

✨ NAME ✨

Tk_GetDash β€” bestie, this is the glow-up where a string becomes a real, valid dash structure πŸ’…

So like, this is a page from the Tk Library Procedures manual, and it's giving conversion core. Let's go 🫢


🌸 SYNOPSIS 🌸

#include <tk.h>

int
Tk_GetDash(interp, string, dashPtr)

πŸŽ€ ARGUMENTS πŸŽ€

  • Tcl_Interp *interp (in) β€” the interpreter we use when we need to report an error, iykyk.
  • const char *string (in) β€” the textual value that's getting converted, periodt.
  • Tk_Dash *dashPtr (out) β€” points to the place where we store the dash pattern value that got converted from string. Must not be NULL. Not negotiable, bestie, don't even try it πŸ’€

πŸ’– DESCRIPTION πŸ’–

Okay so this procedure parses the string and fills in the result inside the Tk_Dash structure. The string can be a list of integers, OR a character string containing only β€œ.,-_” and spaces. If all goes well, TCL_OK is returned and a dash descriptor is stored in the variable that dashPtr points to. But if string doesn't have the proper syntax, then TCL_ERROR is returned, an error message is left in the interpreter's result, and nothing gets stored at *dashPtr. No partial slay, we either ate or we didn't πŸ”₯

⭐ Syntax number one: the integer list

The first possible syntax is a list of integers. Each element represents the number of pixels of a line segment. Only the odd segments are drawn using the β€œoutline” color. The other segments are drawn transparent. The way that it alternates?? iconic honestly.

⭐ Syntax number two: the character list

The second possible syntax is a character list containing only 5 possible characters: β€œ.,-_ ”. The space can be used to enlarge the space between other line elements, and can not occur in the first position of the string. Some examples, bestie, so you can see the vision:

-dash .     = -dash {2 4}
-dash -     = -dash {6 4}
-dash -.    = -dash {6 4 2 4}
-dash -..   = -dash {6 4 2 4 2 4}
-dash {. }  = -dash {2 8}
-dash ,     = -dash {4 4}

The main difference between this syntax and the numeric one is that it is shape-conserving. Which means: all values in the dash list will be multiplied by the line width before display. This ensures that β€œ.” will always be displayed as a dot and β€œ-” always as a dash, regardless of the line width. It's literally so consistent of it πŸ’…

On systems where only a limited set of dash patterns exist, the dash pattern will be displayed as the most close dash pattern that is available. For example, on Windows only the first 4 of the above examples are available; the last 2 examples will be displayed identically to the first one. So like, it's not broken, it's just Windows being Windows πŸ™ˆ


πŸ¦‹ SEE ALSO πŸ¦‹


🌈 KEYWORDS 🌈

  • dash
  • conversion

Okay that's the whole page bestie, you understood it, you're basically a Tk dash expert now πŸ‘‘ This one came from Tk 8.3, and yeah, that's the version and the date vibe this page is serving β€” so like, retro but make it fashion. Mwah πŸ’‹ Tk_GetDash(3tk) forever ✨