canvas::edit::circle(3tk)
β¨ canvas::edit::circle(3tk) β¨
okay so you opened the manual page for canvas::edit::circle, section 3tk, from that little collection called Variations on a canvas β and bestie, it's a whole vibe. circle editing on a Tk canvas. let's get into it π
πΈ NAME πΈ
canvas::edit::circle β editing a circle on a canvas. that's the whole job description, she's focused π
π SYNOPSIS π
package require Tcl 8.5
package require Tk 8.5
package require canvas::edit::points ?0.1?
package require canvas::edit::circle ?0.1?
::canvas::edit circle objectName canvas options...
objectName destroy
objectName enable
objectName disable
objectName active
objectName set minx miny maxx maxy
objectName clear
activeCmd editorObj id
createCmd canvas x y
dataCmd editorObj coordinates
π¦ DESCRIPTION π¦
so this package hands you a class whose instances handle editing a circle on a canvas. you can configure your instances re: how the markers look β you know, the little dudes denoting the circle's principal points. π
and here's the thing, the iconic design choice: instances do not store the edited circle themselves. they delegate that to a configurable object. main character energy, zero attachment π
π INTERACTION π
the circle editor internally uses an instance of package canvas::edit::points, and inherits all the options and behaviours for it. and the color options get additionally applied to the circle element of this editor. slay.
beyond that, it provides an option, -circle-config, to customize the circle item used to render the circle through its principal points. note that it cannot override the inherited color options. sorry bestie, them's the rules π
during interaction, instances execute a state machine, and here's how it goes:
- the user creates two points, at which point the system completes the circle and reports it.
- at that point the system prevents adding more points.
- dragging the points is still possible β which is how you get resizing and moving the circle.
- deleting any of the principal points deletes the entire circle.
- at which point the system is again ready for the creation of a new circle from two points. π
it's giving β¨cycle of lifeβ¨ honestly
π CLASS API π
::canvas::edit circle objectName canvas options...
this, the class command, creates and configures a new instance of a circle editor, named objectName. the instance will be connected to the specified canvas widget.
the result of the command is the fully qualified name of the instance command.
the options accepted here, and their values, are explained in the Options section. iykyk π
π INSTANCE API π
instances of the circle editors provide the following API:
objectName destroy
this method destroys the circle editor and releases all its internal resources.
note that this operation does not destroy the items the editor managed on the attached canvas, nor the canvas itself. the canvas lives on, she's fine π«Ά
the result of the method is an empty string.
objectName enable
this method activates editing of the circle on the canvas. this is the default after instance creation. a call is ignored if the editor is already active.
the result of the method is an empty string.
the complementary method is disable. the interogatory method for the current state is active.
objectName disable
this method disables editing of the circle on the canvas. a call is ignored if the editor is already disabled.
the result of the method is an empty string.
the complementary method is enable. the interogatory method for the current state is active.
objectName active
this method queries the editor state.
the result of the method is a boolean value, true if the editor is active, and false otherwise, i.e. disabled.
the methods to change the state are enable and disable.
objectName set minx miny maxx maxy
this method programmatically sets the circle from the border coordinates. this writes over a previous (possibly partial) circle. no mercy π
the result of the method is an empty string.
note that this method goes through the whole set of callbacks invoked when the principal points are created, i.e. -create-cmd, and, more importantly, -data-cmd.
this is the method through which to load a pre-existing circle into an editor instance. yes queen, that's the one you want β
objectName clear
this method programmatically removes the circle from the editor, making the way free for creating a new one.
the result of the method is an empty string.
note that this method goes through the same callbacks invoked when the user interactively removes a principal point, i.e. -data-cmd.
β¨ OPTIONS β¨
the class command accepts the following options
-active-cmd command-prefixβ the value of this option is a command prefix the editor will invoke when the mouse enters or leaves the circle or one of the principal points managed by the instance.
if not specified it defaults to an empty command which does nothing.
the signature of this command prefix is activeCmd editorObj id
- the id identifies the entered object.
- an empty id indicates that the last entered object was left.
- the value
circleindicates that the circle's outline was entered. - any other value is a code for one of the circle's principal points, i.e.
center, andedge. - the result of this method is ignored.
-add-remove-point eventspecβ the value of this option is an event specification (without bracketing angles) declaring which event will trigger adding and removing a point.
this option can only be set at construction time. π§
the default setup uses different events for adding and removing points, ButtonPress-1 and ButtonPress-2 respectively.
when using this option the same event is used for both operations. this is no problem because adding is bound as canvas-global event while removal is bound to the relevant canvas items.
-circle-config listβ the value of this option is a list of options and their values to be applied to the internal circle item whenever it is regenerated after changes. note that these options cannot override the principal coloring of the circle as applied by the main options-colorand-hilit-color.
if not specified it defaults to the empty list.
-color colorspecβ the value of this option is the fill color for the default item created when adding a point, and no-create-cmdis specified.
the default value is SkyBlue2.
-create-cmd command-prefixβ the value of this option is a command prefix the editor will invoke when it has to create a new principal point.
while this option can be set after construction, it is recommended to use this feature only as a means of inserting custom processing to be done at creation time which remembers and calls the previous value of the option.
if not specified it defaults to a command which will create a black-bordered blue circle of radius 3 centered on the location of the new point.
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. note here that the visual representation of a "principal point" may consist of multiple canvas items in an arbitrary shape.
- the returned list of items is allowed to be empty, and such is taken as signal that the callback vetoed the creation of the principal point.
-data-cmd command-prefixβ the value of this option is a command prefix the editor will invoke when the circle was edited in some way (created, modified, deleted). this is how the editor delegates the actual storage of the circle information to an outside object.
this option can only be set at construction time. π§
if not specified it defaults to an empty string and is ignored by the editor, i.e. not invoked.
the signature of this command prefix is dataCmd editorObj coordinates
- this callback is invoked when the circle was changed either interactively, or programmatically. see instance method
setfor the latter. - the editorObj identifies the instance invoking the callback, whereas coordinates is a list of 4 elements, containing the min x, and y, and the max x and y coordinates of the circle, in this order.
- the result of this method is ignored.
-drag-point eventspecβ the value of this option is an event specification (without bracketing angles) declaring which event will trigger a drag action on points.
this option can only be set at construction time. π§
the default specification is ButtonPress-3.
-hilit-color colorspecβ the value of this option is the highlight color for the default item created when adding a point, and no-highlight-cmdis specified.
the default value is red.
-kind nameβ the value of this option is the canvas item type for the default item created when adding a point, and no-create-cmdis specified. only item types specified through a bounding box are suitable.
the default value is oval.
-radius intβ the value of this option is the radius for the default item created when adding a point, and no-create-cmdis specified.
the default value is 3.
-tag stringβ the value of this option is the name of the canvas tag with which to identify all items of all vertices managed by the editor.
this option can only be set at construction time. π§
if not specified it defaults to CIRCLE
π BUGS, IDEAS, FEEDBACK π
this document, and the package it describes, will undoubtedly contain bugs and other problems. please report such in the category canvas of the Tklib Trackers [http://core.tcl.tk/tklib/reportlist](http://core.tcl.tk/tklib/reportlist). please also report any ideas for enhancements you may have for either package and/or documentation.
not me asking you to file bugs but like. genuinely. they want the feedback bestie π
π KEYWORDS π
canvas, circle, editing
and that's the whole page, bestie π this one came out of tklib, version 0.1, and it's the canvas::edit::circle(3tk) manual β go forth and edit your circles, you've got this ππ
β¨
π¦ where this page comes from
- debian trixie: tklib 0.9-1
- ubuntu questing: tklib 0.9-1
- ubuntu resolute: tklib 0.9-1build1
- ubuntu stonking: tklib 0.9-1build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms