Lines use dots. A line object is either straight (two dots) or bezier curve (four dots).
Common values are canvas to draw and list of instance to calculate ID for XML.
Attributes -width, -outline, -fill for convenience, but without effect, -smooth (to make straight or curvy), -constraint for special properties.
Private data centerDot, group, dots
obj class line -common {
canvas .c
instances {}
} -configure {
-width 2.0
-outline black
-fill ""
-smooth no
-constraint ""
}
obj constructor line args {
set dots {}
if {[string is double -strict [lindex $args 0]]} then {
foreach {x y} $args {
if {[string is double -strict $x]} then {
set dot [new dot -x $x -y $y]
lappend dots $dot
$dot add $self
} else {
# Objekte zu Ende, ab hier Optionen
$self configure $x $y
}
}
} else {
while {[llength $args] > 0} {
if {[string match -* $args]} break
set args [lassign $args dot]
lappend dots $dot
$dot add $self
}
$self configure {*}$args
}
our instances [list {*}[our instances] $self]
my centerDot [new dot]
my group {}
my dots $dots
# $self calcCenter
}
obj destructor line {
$self draw no
foreach dot [$self dots] {
$dot remove $self
}
set index [lsearch [our instances] $self]
our instances [lreplace [our instances] $index $index]
}
© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z