canvas::e...drilateral(3tk)

πŸ“¦
version 0.9 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay so bestie, welcome to canvas::edit::quadrilateral β€” the page all about editing a quadrilateral on a canvas. that's it, that's the whole vibe. a four-sided queen and the tools to drag her corners around. πŸ¦‹


✨ SYNOPSIS ✨

like, here's the whole menu of what you can call. no cap:

package require Tcl 8.5

package require Tk 8.5

package require canvas::edit::points ?0.1?

package require canvas::edit::quadrilateral ?0.2?

::canvas::edit quadrilateral objectName canvas options...

objectName destroy

objectName enable

objectName disable

objectName active

objectName add x y

objectName clear

createCmd canvas x y

highlightCmd on canvas item

highlightCmd off canvas state

dataCmd editorObj coordinates

🌸 DESCRIPTION 🌸

so this package hands you a class, and its instances are the ones doing the actual quadrilateral-editing on a canvas. you can configure them however you like when it comes to how the vertex markers look β€” both the regular look and the highlighted look. two fits, two moods. πŸ‘‘

and here's the tea: instances do NOT store the edited quadrilateral themselves. they delegate that whole job to a configurable object. it's giving "i don't do the paperwork, i have people for that". πŸ’…


πŸ‘‘ CLASS API πŸ‘‘

  • ::canvas::edit quadrilateral objectName canvas options... β€” this is the class command. it creates and configures a brand new instance of a quadrilateral editor, named objectName, and hooks it up to the canvas widget you specified. πŸŽ€

the result of the command is the fully qualified name of the instance command β€” that's your handle for everything else.

the options it accepts, and what their values mean, are all down in the Options section. go look, i'll wait. 🌈


πŸ’œ INSTANCE API πŸ’œ

instances of the quadrilateral editors give you this whole API, and honestly? she serves:

  • objectName destroy β€” this method destroys the quadrilateral editor and releases all its internal resources. bye bestie. πŸ’€
heads up: this does not destroy the items the editor managed on the attached canvas, and it does not destroy the canvas itself. the editor leaves, the furniture stays.

the result of the method is an empty string.

  • objectName enable β€” activates editing of the quadrilateral on the canvas. this is the default after instance creation, so she's already on. if the editor is already active, the call is just ignored, no drama. ✨

the result of the method is an empty string.

the complementary method is disable, and the interrogatory method for the current state is active.

  • objectName disable β€” disables editing of the quadrilateral on the canvas. if the editor is already disabled, the call is ignored. she's unbothered, she's offline. πŸ™ˆ

the result of the method is an empty string.

the complementary method is enable, and the interrogatory method for the current state is active.

  • objectName active β€” queries the editor state. vibe check, basically. 🫢

the result is a boolean value: true if the editor is active, false otherwise (i.e. disabled).

the methods that change the state are enable and disable.

  • objectName add x y β€” programmatically adds a vertex at the location you specify to the quadrilateral. feeding her corners by hand, love that for us. πŸ“

the result of the method is an empty string.

note that this method goes through the whole set of callbacks invoked when the user interactively creates a vertex β€” that's -create-cmd, and, more importantly, -data-cmd.

this is the method for loading the vertices of a pre-existing quadrilateral into an editor instance. that's the move. ⭐

and listen: at most 4 vertices can be specified, and at least 4 must be specified for the quadrilateral to be complete. four sides, four corners, that's the whole point bestie.
  • objectName clear β€” programmatically unsets the quadrilateral in the editor. everything gone, no trace, main character wiped from the timeline. πŸ’…

the result of the method is an empty string.

note that this method goes through the same callback invoked when the user interactively removes a vertex, i.e. -data-cmd.


πŸŽ€ OPTIONS πŸŽ€

the class command accepts these options, and every single one of them matters, so don't skip:

  • -convex boolean β€” this value is a boolean flag. when the flag is set, the editor will accept only convex quadrilaterals, and will reject all operations that would result in a violation of convexity. she has standards. no weird folded-up shapes on her watch. πŸ”₯

this option can only be set at construction time.

if you don't specify it, it defaults to false, i.e. acceptance of any quadrilateral. live your truth, any shape goes.

  • -tag string β€” the value is the name of the canvas tag used to identify all items of all quadrilaterals managed by the editor. a little name badge for the whole squad. 🏷️

this option can only be set at construction time.

if you don't specify it, it defaults to QUADRILATERAL.

  • -create-cmd command-prefix β€” the value is a command prefix the editor invokes when it has to create a new vertex. πŸ¦‹

this option can only be set at construction time.

if you don't specify it, it defaults to a command which creates a black-bordered blue circle of radius 3 centered on the location of the new point. iconic little dot, honestly.

the signature of this command prefix is:

  • createCmd canvas x y β€” the result of the command prefix must be a list of the canvas items it created to represent the marker. and note: the visual representation of a "vertex" may consist of multiple canvas items in an arbitrary shape. it's a whole ensemble, not a solo act. ✨
  • -highlight-cmd command-prefix β€” the value is a command prefix the editor invokes when it has to (un)highlight a vertex. πŸ’–

this option can only be set at construction time.

if you don't specify it, it defaults to a command which re-colors the item to highlight in red (and restores the color for unhighlighting). red is her color, periodt.

the two signatures of this command prefix are:

  • highlightCmd on canvas item β€” this method of the command prefix has to perform whatever is needed to highlight the vertex the item is a part of (remember that note up there about quadrilaterals being allowed to be constructed from multiple canvas items πŸ‘€).

the result of the command can be anything, and it will be passed as is as the argument state to the off method.

  • highlightCmd off canvas state β€” this method is invoked to unhighlight a vertex described by the state, which is the unchanged result of the on method of the command prefix. the result of this method is ignored.

note that any interaction between dragging and highlighting of the quadrilateral is handled within the editor, and the callback bears no responsibility for doing such. not her job, not her problem. πŸ™…β€β™€οΈ

  • -data-cmd command-prefix β€” the value is a command prefix the editor invokes when the quadrilateral was edited in some way. this is how the editor delegates the actual storage of quadrilateral information to an outside object. outsourcing queen. πŸ‘‘

this option can only be set at construction time.

if you don't specify it, it defaults to an empty string and is ignored by the editor, i.e. not invoked at all. ghosted, fr fr.

the signature of this command prefix is:

  • dataCmd editorObj coordinates β€” this callback is invoked when the quadrilateral was changed, either interactively or programmatically. (see instance method add for the programmatic route. 🫢)

the editorObj identifies the instance invoking the callback, whereas coordinates is a list of vertex locations, with each location a pair of x- and y-coordinates.

the result of this method is ignored.


😭 BUGS, IDEAS, FEEDBACK 😭

this document, and the package it describes, will undoubtedly contain bugs and other problems. no cap, they said it themselves. πŸ˜”

please report such in the category canvas of the Tklib Trackers [http://core.tcl.tk/tklib/reportlist]. and please also report any ideas for enhancements you may have for either the package and/or the documentation β€” she's listening, she wants your thoughts. πŸŽ€


⭐ KEYWORDS ⭐

canvas, concave, convex, editing, non-convex, quadrilateral


and that's the whole page bestie, we ate and left no crumbs πŸ’…βœ¨ this was canvas::edit::quadrilateral from the tklib crew, version 0.2, manual section 3tk β€” mwah, go forth and edit your four-sided icons. πŸ¦‹πŸ’–πŸŽ€

πŸ“¦ where this page comes from