poFti 1.0.0 Reference Manual

poFti - FTI handling with TclTop

poFti offers functionality to handle File Type Icons (FTI) using the Tcl scripting language.

For this purpose, poFti implements two TclOO classes Icon and Item, as well as some static commands.

File Type Icons can be read from file or string, written to file or created by using a Tcl script (see demo createSpiralColored.tcl).

An icon can be displayed in a Tk canvas (see script ftiBatch.tcl) and captured from the canvas into a Tk photo image or written to an image file. Additionally a square or isometric grid can be drawn into the canvas.

Colors can be specified in three different ways:

Important links:

::poFtiTop

CommandspoFti, Top

DrawGrid [::poFti]poFti, Top

Draw a grid into the Tk canvas.

DrawGrid canvasId ?args?
Parameters
canvasIdIdentifier of the canvas.
argsOptions described below.
-color <string>Tk color specification. Default: grey.
-height <int>Height of the drawn grid in pixel.
-type <string>Grid type: none, square or isometric. Default: isometric.
-width <int>Width of the drawn grid in pixel.
Description

If -width or -height is not specified, the width or height of the canvas is used.

The grid canvas items are assigned tag FtiGrid.

See also

Icon::Draw

proc ::poFti::DrawGrid {canvasId args} {

    # Draw a grid into the Tk canvas.
    #
    # canvasId - Identifier of the canvas.
    # args     - Options described below.
    #
    # -width <int>    - Width of the drawn grid in pixel.
    # -height <int>   - Height of the drawn grid in pixel.
    # -color <string> - Tk color specification. Default: `grey`.
    # -type <string>  - Grid type: `none`, `square` or `isometric`.
    #                   Default: `isometric`.
    #
    # If `-width` or `-height` is not specified, the
    # width or height of the canvas is used.
    #
    # The grid canvas items are assigned tag `FtiGrid`.
    #
    # See also: Icon::Draw

    set opts [dict create  -width  0  -height 0  -color  "grey"  -type   "square"  ]
    foreach { key value } $args {
        if { [dict exists $opts $key] } {
            if { $value eq "" } {
                error "DrawGrid: No value specified for key \"$key\"."
            }
            dict set opts $key $value
        } else {
            error "DrawGrid: Unknown option \"$key\" specified."
        }
    }

    set width  [dict get $opts "-width"]
    set height [dict get $opts "-height"]
    if { $width <= 0 } {
        set width [$canvasId cget -width]
    }
    if { $height <= 0 } {
        set height [$canvasId cget -height]
    }
    set color [dict get $opts "-color"]
    set type  [dict get $opts "-type"]

    $canvasId delete "FtiGrid"
    if { $type eq "none" } {
        return
    }

    # IconSmith seems to use a 2:1 pixel pattern ratio.
    # See https://en.wikipedia.org/wiki/Isometric_video_game_graphics
    # chapter "Differences from true isometric projection".
    set angle [expr { atan (1.0 / 2.0) }]
    set xstep [expr {$width  / 20 }]
    set ystep [expr {$height / 20 }]
    for { set y $height } { $y >= 0 } { incr y -$ystep } {
        for { set x 0 } { $x <= $width } { incr x $xstep } {
            set xi $x
            if { $type eq "isometric" && $x % 2 } {
                set yi [expr { int ($y + atan($angle) * $ystep) }]
            } else {
                set yi $y
            }
            set x1 [expr { $xi - 3}]
            set y1 [expr { $yi - 3}]
            set x2 [expr { $xi + 3}]
            set y2 [expr { $yi + 3}]
            $canvasId create line $x1 $yi $x2 $yi -fill $color -tags [list "FtiGrid"]
            $canvasId create line $xi $y1 $xi $y2 -fill $color -tags [list "FtiGrid"]
        }
    }
}

generic.doc [::poFti]poFti, Top

Returns the string description of icon generic.doc.

generic.doc
Return value

Returns the string description of icon generic.doc.

proc ::poFti::generic.doc {} {

            # Returns the string description of icon `generic.doc`.

            return {
    #	Icon Shadow
    		color(shadowcolor);
    		bgnpolygon();
    			vertex(38.83, 0.22);
    			vertex(22.00, 9.12);
    			vertex(60.55, 28.78);
    			vertex(77.82, 20.20);
    		endpolygon();

    #	Paper Sheet 1
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(22.00, 19.87);
    			vertex(22.00, 79.50);
    			vertex(60.01, 98.93);
    			vertex(60.01, 39.20);
    		endoutlinepolygon(outlinecolor);

    #	Paper Sheet 2
    		bgnoutlinepolygon();
    			vertex(30.69, 15.53);
    			vertex(30.69, 74.83);
    			vertex(68.70, 94.59);
    			vertex(68.70, 34.97);
    		endoutlinepolygon(outlinecolor);

    #	Third Sheet of Paper -- Closed
    		bgnoutlinepolygon();
    			vertex(39.59, 11.51);
    			vertex(39.59, 70.48);
    			vertex(77.39, 89.92);
    			vertex(77.39, 30.84);
    		endoutlinepolygon(outlinecolor);
            }
}

generic.doc.closed [::poFti]poFti, Top

Returns the string description of icon generic.doc.closed.

generic.doc.closed
Return value

Returns the string description of icon generic.doc.closed.

proc ::poFti::generic.doc.closed {} {

            # Returns the string description of icon `generic.doc.closed`.

            return {
    #	Third Sheet of Paper -- Closed
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(39.59, 11.51);
    			vertex(39.59, 70.48);
    			vertex(77.39, 89.92);
    			vertex(77.39, 30.84);
    		endoutlinepolygon(outlinecolor);
            }
}

generic.doc.open [::poFti]poFti, Top

Returns the string description of icon generic.doc.open.

generic.doc.open
Return value

Returns the string description of icon generic.doc.open.

proc ::poFti::generic.doc.open {} {

            # Returns the string description of icon `generic.doc.open`.

            return {
    #	Open Paper Sheet 3 -- Back Part
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(39.59, 11.51);
    			vertex(39.59, 70.48);
    			vertex(51.43, 76.45);
    			vertex(53.60, 76.78);
    			vertex(54.91, 76.45);
    			vertex(57.29, 76.13);
    			vertex(58.38, 75.48);
    			vertex(59.79, 74.61);
    			vertex(61.42, 73.09);
    			vertex(62.51, 71.35);
    			vertex(77.39, 30.84);
    		endoutlinepolygon(outlinecolor);

    #	Open Paper Sheet 3 -- Furled Part
    		bgnoutlinepolygon();
    			vertex(77.39, 30.84);
    			vertex(55.01, 53.11);
    			vertex(56.53, 55.17);
    			vertex(58.16, 57.23);
    			vertex(59.25, 58.75);
    			vertex(60.34, 60.27);
    			vertex(61.10, 61.90);
    			vertex(62.29, 63.86);
    			vertex(62.83, 66.14);
    			vertex(62.72, 68.64);
    			vertex(62.51, 71.35);
    		endoutlinepolygon(outlinecolor);
            }
}

generic.doc.pre [::poFti]poFti, Top

Returns the string description of icon generic.doc.pre.

generic.doc.pre
Return value

Returns the string description of icon generic.doc.pre.

proc ::poFti::generic.doc.pre {} {

            # Returns the string description of icon `generic.doc.pre`.

            return {
    #	Icon Shadow
    		color(shadowcolor);
    		bgnpolygon();
    			vertex(38.83, 0.22);
    			vertex(22.00, 9.12);
    			vertex(60.55, 28.78);
    			vertex(77.82, 20.20);
    		endpolygon();

    #	Paper Sheet 1
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(22.00, 19.87);
    			vertex(22.00, 79.50);
    			vertex(60.01, 98.93);
    			vertex(60.01, 39.20);
    		endoutlinepolygon(outlinecolor);

    #	Paper Sheet 2
    		bgnoutlinepolygon();
    			vertex(30.69, 15.53);
    			vertex(30.69, 74.83);
    			vertex(68.70, 94.59);
    			vertex(68.70, 34.97);
    		endoutlinepolygon(outlinecolor);
            }
}

generic.exec.closed [::poFti]poFti, Top

Returns the string description of icon generic.exec.closed.

generic.exec.closed
Return value

Returns the string description of icon generic.exec.closed.

proc ::poFti::generic.exec.closed {} {

            # Returns the string description of icon `generic.exec.closed`.

            return {
    #		Icon Shadow - Closed
    		color(shadowcolor);
    		bgnpolygon();
    			vertex(50.00, 0.00);
    			vertex(10.00, 20.00);
    			vertex(50.00, 40.00);
    			vertex(90.00, 20.00);
    		endpolygon();

    #		Icon - Closed
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(50.00, 10.00);
    			vertex(18.00, 26.00);
    			vertex(15.66, 27.43);
    			vertex(14.00, 29.00);
    			vertex(12.00, 31.03);
    			vertex(10.74, 33.49);
    			vertex(10.00, 36.00);
    			vertex(10.00, 40.00);
    			vertex(50.00, 60.00);
    			vertex(50.00, 56.00);
    			vertex(51.00, 53.00);
    			vertex(52.34, 50.75);
    			vertex(53.54, 49.27);
    			vertex(55.00, 48.00);
    			vertex(58.00, 46.00);
    			vertex(90.00, 30.00);
    		endoutlinepolygon(outlinecolor);
            }
}

generic.exec.open [::poFti]poFti, Top

Returns the string description of icon generic.exec.open.

generic.exec.open
Return value

Returns the string description of icon generic.exec.open.

proc ::poFti::generic.exec.open {} {

            # Returns the string description of icon `generic.exec.open`.

            return {
    #		Icon Shadow - Open
    		color(shadowcolor);
    		bgnpolygon();
    			vertex(18.00, 16.00);
    			vertex(10.00, 20.00);
    			vertex(50.00, 40.00);
    			vertex(58.00, 36.00);
    		endpolygon();

    #		Icon - Open
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(18.00, 26.00);
    			vertex(15.84, 27.28);
    			vertex(14.00, 29.00);
    			vertex(12.10, 31.27);
    			vertex(10.90, 33.20);
    			vertex(10.00, 36.00);
    			vertex(10.00, 40.00);
    			vertex(10.00, 80.00);
    			vertex(50.00, 100.00);
    			vertex(50.00, 60.00);
    			vertex(50.00, 56.00);
    			vertex(50.88, 52.84);
    			vertex(52.04, 50.70);
    			vertex(53.48, 49.14);
    			vertex(55.00, 48.00);
    			vertex(58.00, 46.00);
    		endoutlinepolygon(outlinecolor);
            }
}

generic.folder.closed [::poFti]poFti, Top

Returns the string description of icon generic.folder.closed.

generic.folder.closed
Return value

Returns the string description of icon generic.folder.closed.

proc ::poFti::generic.folder.closed {} {

            # Returns the string description of icon `generic.folder.closed`.

            return {
    #	Shadow Always Same Closed or Open
    		color(shadowcolor);
    		bgnpolygon();
    			vertex(26.37, 0.00);
    			vertex(15.00, 5.69);
    			vertex(71.86, 34.11);
    			vertex(83.23, 28.43);
    		endpolygon();

    #	Folder Back Polygon 1
    		color(iconcolor);
    		bgnpolygon();
    			vertex(21.14, 13.87);
    			vertex(17.27, 15.81);
    			vertex(17.27, 63.22);
    			vertex(26.83, 68.23);
    			vertex(45.25, 77.67);
    			vertex(73.22, 91.65);
    			vertex(73.22, 44.01);
    			vertex(76.97, 41.85);
    		endpolygon();

    #	Folder Back Polygon 2 -- Tab on Top
    		bgnpolygon();
    			vertex(26.83, 68.23);
    			vertex(28.42, 73.00);
    			vertex(43.66, 81.76);
    			vertex(45.25, 77.67);
    		endpolygon();

    #	Folder Back Outline
    		color(outlinecolor);
    		bgnline();
    			vertex(21.14, 13.87);
    			vertex(17.27, 15.81);
    			vertex(17.27, 63.22);
    			vertex(26.83, 68.23);
    			vertex(28.42, 73.00);
    			vertex(28.42, 73.00);
    			vertex(43.66, 81.76);
    			vertex(45.25, 77.67);
    			vertex(73.22, 91.65);
    			vertex(73.22, 44.01);
    			vertex(76.97, 41.85);
    		endline();

    #	Folder Front Polygon -- Small Tab Indent
    #	Folder Front Outline
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(21.14, 13.87);
    			vertex(21.14, 60.50);
    			vertex(29.44, 64.82);
    			vertex(31.49, 61.06);
    			vertex(47.07, 68.80);
    			vertex(47.64, 73.91);
    			vertex(76.97, 88.47);
    			vertex(76.97, 41.85);
    		endoutlinepolygon(outlinecolor);
            }
}

generic.folder.open [::poFti]poFti, Top

Returns the string description of icon generic.folder.open.

generic.folder.open
Return value

Returns the string description of icon generic.folder.open.

proc ::poFti::generic.folder.open {} {

            # Returns the string description of icon `generic.folder.open`.

            return {
    #	Folder Back Polygon 2 -- Tab on Top
    		color(iconcolor);
    		bgnpolygon();
    			vertex(26.83, 68.23);
    			vertex(28.42, 73.00);
    			vertex(43.66, 81.76);
    			vertex(45.25, 77.67);
    		endpolygon();

    #	Folder Back Polygon 1
    		bgnpolygon();
    			vertex(21.14, 13.87);
    			vertex(17.27, 15.81);
    			vertex(17.27, 63.22);
    			vertex(26.83, 68.23);
    			vertex(45.25, 77.67);
    			vertex(73.22, 91.65);
    			vertex(73.22, 44.01);
    			vertex(76.97, 41.85);
    		endpolygon();

    #	Folder Back Outline
    		color(outlinecolor);
    		bgnline();
    			vertex(21.14, 13.87);
    			vertex(17.27, 15.81);
    			vertex(17.27, 63.22);
    			vertex(26.83, 68.23);
    			vertex(28.42, 73.00);
    			vertex(28.42, 73.00);
    			vertex(43.66, 81.76);
    			vertex(45.25, 77.67);
    			vertex(73.22, 91.65);
    			vertex(73.22, 44.01);
    		endline();

    #	Shadow Always Same Closed or Open
    		color(shadowcolor);
    		bgnpolygon();
    			vertex(26.37, 0.00);
    			vertex(15.00, 5.69);
    			vertex(71.86, 34.11);
    			vertex(83.23, 28.43);
    		endpolygon();

    #	Folder Front Opened
    		color(iconcolor);
    		bgnpolygon();
    			vertex(21.14, 13.87);
    			vertex(42.06, 56.52);
    			vertex(49.57, 60.61);
    			vertex(49.57, 55.26);
    			vertex(64.81, 62.88);
    			vertex(68.90, 69.93);
    			vertex(97.90, 84.49);
    			vertex(76.97, 41.85);
    		endpolygon();

    #	Folder Front Opened -- Small Tab Indent
    		bgnpolygon();
    			vertex(39.33, 50.72);
    			vertex(42.18, 56.74);
    			vertex(49.57, 60.61);
    			vertex(49.57, 55.26);
    		endpolygon();

    #	Folder Front Opened Outline
    		bgnoutlinepolygon();
    			vertex(21.14, 13.87);
    			vertex(41.95, 56.52);
    			vertex(49.57, 60.61);
    			vertex(49.57, 55.26);
    			vertex(64.81, 62.88);
    			vertex(68.90, 69.93);
    			vertex(97.90, 84.49);
    			vertex(76.97, 41.85);
    		endoutlinepolygon(outlinecolor);
            }
}

generic.link [::poFti]poFti, Top

Returns the string description of icon generic.link.

generic.link
Return value

Returns the string description of icon generic.link.

generic.panel.closed [::poFti]poFti, Top

Returns the string description of icon generic.panel.closed.

generic.panel.closed
Return value

Returns the string description of icon generic.panel.closed.

proc ::poFti::generic.panel.closed {} {

            # Returns the string description of icon `generic.panel.closed`.

            return {
    #	Path_0
    		color(shadowcolor);
    		bgnpolygon();
    			vertex(5.00, 22.50);
    			vertex(50.00, 0.00);
    			vertex(90.00, 20.00);
    			vertex(45.00, 42.50);
    		endpolygon();

    #	Path_1
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(44.80, 55.90);
    			vertex(40.00, 55.00);
    			vertex(10.00, 40.00);
    			vertex(7.00, 37.30);
    			vertex(5.00, 32.50);
    			vertex(50.00, 10.00);
    			vertex(90.00, 30.00);
    			vertex(88.00, 34.40);
    			vertex(85.00, 37.50);
    			vertex(50.00, 55.00);
    		endoutlinepolygon(outlinecolor);

    #	Path_2
    		color(-249);
    		bgnoutlinepolygon();
    			vertex(15.80, 36.90);
    			vertex(13.96, 34.62);
    			vertex(47.40, 18.00);
    			vertex(49.40, 20.40);
    			vertex(51.40, 21.60);
    			vertex(17.96, 38.22);
    		endoutlinepolygon(outlinecolor);

    #	Path_3
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(27.86, 31.07);
    			vertex(30.10, 32.18);
    			vertex(42.92, 25.74);
    			vertex(40.46, 24.47);
    			vertex(38.92, 22.14);
    			vertex(26.10, 28.59);
    		endoutlinepolygon(outlinecolor);

    #	Path_4
    		color(-119);
    		bgnline();
    			vertex(37.07, 25.78);
    			vertex(29.32, 29.65);
    		endline();

    #	Path_6
    		color(outlinecolor);
    		bgnline();
    			vertex(34.19, 27.78);
    			vertex(33.63, 27.50);
    		endline();
            }
}

generic.panel.open [::poFti]poFti, Top

Returns the string description of icon generic.panel.open.

generic.panel.open
Return value

Returns the string description of icon generic.panel.open.

proc ::poFti::generic.panel.open {} {

            # Returns the string description of icon `generic.panel.open`.

            return {
    #	Path_0
    		color(shadowcolor);
    		bgnpolygon();
    			vertex(5.00, 12.50);
    			vertex(15.00, 7.50);
    			vertex(20.40, 7.20);
    			vertex(25.00, 7.50);
    			vertex(65.00, 27.50);
    			vertex(65.00, 32.50);
    			vertex(55.00, 37.50);
    		endpolygon();

    #	Path_1
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(10.00, 80.00);
    			vertex(10.00, 20.00);
    			vertex(50.00, 40.00);
    			vertex(53.20, 43.00);
    			vertex(55.00, 47.50);
    			vertex(55.00, 92.50);
    			vertex(53.20, 96.80);
    			vertex(50.00, 100.00);
    		endoutlinepolygon(outlinecolor);

    #	Path_2
    		color(-249);
    		bgnoutlinepolygon();
    			vertex(17.40, 74.80);
    			vertex(14.80, 74.00);
    			vertex(14.80, 29.00);
    			vertex(17.80, 30.80);
    			vertex(20.40, 33.60);
    			vertex(20.40, 74.80);
    		endoutlinepolygon(outlinecolor);

    #	Path_3
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(17.20, 68.60);
    			vertex(20.40, 68.00);
    			vertex(20.40, 54.30);
    			vertex(17.20, 52.60);
    			vertex(14.80, 52.00);
    			vertex(14.80, 66.80);
    		endoutlinepolygon(outlinecolor);

    #	Path_4
    		color(-119);
    		bgnline();
    			vertex(17.00, 55.40);
    			vertex(17.05, 64.12);
    		endline();

    #	Path_6
    		color(outlinecolor);
    		bgnline();
    			vertex(17.36, 59.85);
    			vertex(16.79, 59.57);
    		endline();
            }
}

generic.printer.closed [::poFti]poFti, Top

Returns the string description of icon generic.printer.closed.

generic.printer.closed
Return value

Returns the string description of icon generic.printer.closed.

proc ::poFti::generic.printer.closed {} {

            # Returns the string description of icon `generic.printer.closed`.

            return {
    #	Generic Executable Icon Shadow - Closed
    		color(shadowcolor);
    		bgnpolygon();
    			vertex(50.00, 0.00);
    			vertex(10.00, 20.00);
    			vertex(50.00, 40.00);
    			vertex(90.00, 20.00);
    		endpolygon();

    #	Generic Executable Icon - Closed
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(50.00, 10.00);
    			vertex(18.00, 26.00);
    			vertex(15.00, 27.50);
    			vertex(13.40, 28.80);
    			vertex(12.00, 30.20);
    			vertex(10.60, 32.60);
    			vertex(10.00, 36.00);
    			vertex(10.00, 40.00);
    			vertex(50.00, 60.00);
    			vertex(50.00, 56.00);
    			vertex(51.00, 53.00);
    			vertex(52.00, 52.00);
    			vertex(54.00, 49.00);
    			vertex(55.00, 48.00);
    			vertex(58.00, 46.00);
    			vertex(90.00, 30.00);
    		endoutlinepolygon(outlinecolor);

    #	Drop on Top of Platform
    #	Printer Body
    		bgnoutlinepolygon();
    			vertex(51.48, 23.49);
    			vertex(31.38, 33.54);
    			vertex(30.62, 34.40);
    			vertex(30.25, 35.27);
    			vertex(30.08, 36.49);
    			vertex(30.08, 43.89);
    			vertex(30.22, 44.86);
    			vertex(30.65, 45.41);
    			vertex(31.58, 45.99);
    			vertex(64.80, 62.50);
    			vertex(84.98, 52.49);
    			vertex(86.28, 51.67);
    			vertex(87.04, 50.92);
    			vertex(87.48, 49.70);
    			vertex(87.50, 41.25);
    			vertex(86.95, 40.20);
    			vertex(85.98, 39.49);
    			vertex(53.98, 23.49);
    			vertex(53.28, 23.19);
    			vertex(52.29, 23.20);
    		endoutlinepolygon(outlinecolor);

    #	Slot
    		color(shadowcolor);
    		bgnoutlinepolygon();
    			vertex(41.89, 43.03);
    			vertex(36.89, 45.53);
    			vertex(64.39, 59.28);
    			vertex(69.39, 56.78);
    		endoutlinepolygon(outlinecolor);

    #	Back Button
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(71.02, 51.81);
    			vertex(67.02, 53.81);
    			vertex(71.02, 55.81);
    			vertex(75.02, 53.81);
    		endoutlinepolygon(outlinecolor);

    #	Front Button
    		bgnoutlinepolygon();
    			vertex(76.57, 48.89);
    			vertex(72.57, 50.89);
    			vertex(76.57, 52.89);
    			vertex(80.57, 50.89);
    		endoutlinepolygon(outlinecolor);

    #	Knob Side
    		bgnoutlinepolygon();
    			vertex(36.44, 32.49);
    			vertex(33.98, 40.49);
    			vertex(36.42, 41.70);
    			vertex(37.36, 41.47);
    			vertex(38.92, 40.40);
    			vertex(39.75, 38.74);
    			vertex(40.00, 37.28);
    			vertex(39.84, 35.68);
    			vertex(39.46, 34.68);
    		endoutlinepolygon(outlinecolor);

    #	Knob Face
    		bgnoutlinepolygon();
    			vertex(36.44, 32.49);
    			vertex(35.63, 32.56);
    			vertex(34.48, 32.93);
    			vertex(33.64, 33.59);
    			vertex(32.74, 34.99);
    			vertex(32.35, 36.53);
    			vertex(32.34, 38.49);
    			vertex(32.96, 39.81);
    			vertex(33.98, 40.49);
    			vertex(35.21, 40.40);
    			vertex(36.23, 39.66);
    			vertex(37.06, 38.74);
    			vertex(37.64, 37.19);
    			vertex(37.84, 35.79);
    			vertex(37.74, 34.19);
    			vertex(37.36, 33.15);
    		endoutlinepolygon(outlinecolor);

    #	Side Edge
    		color(outlinecolor);
    		bgnline();
    			vertex(52.18, 24.49);
    			vertex(52.18, 32.49);
    			vertex(52.08, 33.29);
    			vertex(51.68, 33.89);
    			vertex(51.08, 34.19);
    			vertex(45.90, 36.78);
    		endline();

    #	Front Edge
    		bgnline();
    			vertex(54.08, 35.59);
    			vertex(83.98, 50.49);
    		endline();

    #	Paper
    		color(iconcolor);
    		bgnpolygon();
    			vertex(65.56, 56.53);
    			vertex(40.36, 43.88);
    			vertex(39.86, 47.83);
    			vertex(38.76, 51.73);
    			vertex(64.47, 65.15);
    			vertex(64.76, 63.13);
    			vertex(65.11, 61.47);
    			vertex(65.30, 58.91);
    		endpolygon();

    #	Paper
    		bgnpolygon();
    			vertex(38.68, 51.69);
    			vertex(37.38, 55.59);
    			vertex(61.97, 71.54);
    			vertex(63.03, 69.43);
    			vertex(63.78, 67.09);
    			vertex(64.39, 65.11);
    		endpolygon();

    #	Paper
    		bgnpolygon();
    			vertex(36.28, 58.09);
    			vertex(33.81, 60.69);
    			vertex(56.92, 75.75);
    			vertex(59.97, 73.64);
    		endpolygon();

    #	Paper
    		bgnpolygon();
    			vertex(33.81, 60.69);
    			vertex(30.72, 62.75);
    			vertex(48.78, 76.84);
    			vertex(50.72, 76.98);
    			vertex(53.78, 76.84);
    			vertex(56.92, 75.75);
    		endpolygon();

    #	Paper
    		bgnpolygon();
    			vertex(30.72, 62.75);
    			vertex(27.32, 63.68);
    			vertex(23.78, 64.34);
    			vertex(48.78, 76.84);
    		endpolygon();

    #	Paper
    		bgnpolygon();
    			vertex(37.36, 55.58);
    			vertex(36.26, 58.08);
    			vertex(59.95, 73.63);
    			vertex(61.95, 71.53);
    		endpolygon();

    #	Paper
    		color(outlinecolor);
    		bgnclosedline();
    			vertex(65.48, 56.49);
    			vertex(40.28, 43.84);
    			vertex(39.78, 47.79);
    			vertex(38.68, 51.69);
    			vertex(37.38, 55.59);
    			vertex(36.28, 58.09);
    			vertex(33.81, 60.69);
    			vertex(30.72, 62.75);
    			vertex(27.32, 63.68);
    			vertex(23.78, 64.34);
    			vertex(48.78, 76.84);
    			vertex(50.72, 76.98);
    			vertex(53.78, 76.84);
    			vertex(56.92, 75.75);
    			vertex(59.97, 73.64);
    			vertex(61.97, 71.54);
    			vertex(63.03, 69.43);
    			vertex(63.78, 67.09);
    			vertex(64.39, 65.11);
    			vertex(64.68, 63.09);
    			vertex(65.03, 61.43);
    			vertex(65.22, 58.87);
    		endclosedline();
            }
}

generic.printer.open [::poFti]poFti, Top

Returns the string description of icon generic.printer.open.

generic.printer.open
Return value

Returns the string description of icon generic.printer.open.

proc ::poFti::generic.printer.open {} {

            # Returns the string description of icon `generic.printer.open`.

            return {
    #	Generic Executable Shadow - Open
    		color(shadowcolor);
    		bgnpolygon();
    			vertex(18.00, 16.00);
    			vertex(10.00, 20.00);
    			vertex(50.00, 40.00);
    			vertex(58.00, 36.00);
    		endpolygon();

    #	Generic Executable Icon - Open
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(18.00, 26.00);
    			vertex(15.00, 27.50);
    			vertex(13.51, 28.94);
    			vertex(12.18, 30.66);
    			vertex(10.80, 33.00);
    			vertex(10.00, 36.00);
    			vertex(10.00, 40.00);
    			vertex(10.00, 80.00);
    			vertex(50.00, 100.00);
    			vertex(50.00, 60.00);
    			vertex(50.00, 56.00);
    			vertex(51.00, 54.00);
    			vertex(52.00, 52.00);
    			vertex(54.00, 49.00);
    			vertex(55.00, 48.00);
    			vertex(58.00, 46.00);
    		endoutlinepolygon(outlinecolor);

    #	Drop on Top of Platform
    #	Printer Body
    		bgnoutlinepolygon();
    			vertex(51.48, 23.49);
    			vertex(31.38, 33.54);
    			vertex(30.62, 34.40);
    			vertex(30.25, 35.27);
    			vertex(30.08, 36.49);
    			vertex(30.08, 43.89);
    			vertex(30.22, 44.86);
    			vertex(30.65, 45.41);
    			vertex(31.58, 45.99);
    			vertex(64.80, 62.50);
    			vertex(84.98, 52.49);
    			vertex(86.28, 51.67);
    			vertex(87.04, 50.92);
    			vertex(87.48, 49.70);
    			vertex(87.50, 41.25);
    			vertex(86.95, 40.20);
    			vertex(85.98, 39.49);
    			vertex(53.98, 23.49);
    			vertex(53.28, 23.19);
    			vertex(52.29, 23.20);
    		endoutlinepolygon(outlinecolor);

    #	Slot
    		color(shadowcolor);
    		bgnoutlinepolygon();
    			vertex(41.89, 43.03);
    			vertex(36.89, 45.53);
    			vertex(64.39, 59.28);
    			vertex(69.39, 56.78);
    		endoutlinepolygon(outlinecolor);

    #	Back Button
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(71.02, 51.81);
    			vertex(67.02, 53.81);
    			vertex(71.02, 55.81);
    			vertex(75.02, 53.81);
    		endoutlinepolygon(outlinecolor);

    #	Front Button
    		bgnoutlinepolygon();
    			vertex(76.57, 48.89);
    			vertex(72.57, 50.89);
    			vertex(76.57, 52.89);
    			vertex(80.57, 50.89);
    		endoutlinepolygon(outlinecolor);

    #	Knob Side
    		bgnoutlinepolygon();
    			vertex(36.44, 32.49);
    			vertex(33.98, 40.49);
    			vertex(36.42, 41.70);
    			vertex(37.36, 41.47);
    			vertex(38.92, 40.40);
    			vertex(39.75, 38.74);
    			vertex(40.00, 37.28);
    			vertex(39.84, 35.68);
    			vertex(39.46, 34.68);
    		endoutlinepolygon(outlinecolor);

    #	Knob Face
    		bgnoutlinepolygon();
    			vertex(36.44, 32.49);
    			vertex(35.63, 32.56);
    			vertex(34.48, 32.93);
    			vertex(33.64, 33.59);
    			vertex(32.74, 34.99);
    			vertex(32.35, 36.53);
    			vertex(32.34, 38.49);
    			vertex(32.96, 39.81);
    			vertex(33.98, 40.49);
    			vertex(35.21, 40.40);
    			vertex(36.23, 39.66);
    			vertex(37.06, 38.74);
    			vertex(37.64, 37.19);
    			vertex(37.84, 35.79);
    			vertex(37.74, 34.19);
    			vertex(37.36, 33.15);
    		endoutlinepolygon(outlinecolor);

    #	Side Edge
    		color(outlinecolor);
    		bgnline();
    			vertex(52.18, 24.49);
    			vertex(52.18, 32.49);
    			vertex(52.08, 33.29);
    			vertex(51.68, 33.89);
    			vertex(51.08, 34.19);
    			vertex(45.90, 36.78);
    		endline();

    #	Front Edge
    		bgnline();
    			vertex(54.08, 35.59);
    			vertex(83.98, 50.49);
    		endline();

    #	Paper
    		color(iconcolor);
    		bgnpolygon();
    			vertex(65.56, 56.53);
    			vertex(40.36, 43.88);
    			vertex(39.86, 47.83);
    			vertex(38.76, 51.73);
    			vertex(64.47, 65.15);
    			vertex(64.76, 63.13);
    			vertex(65.11, 61.47);
    			vertex(65.30, 58.91);
    		endpolygon();

    #	Paper
    		bgnpolygon();
    			vertex(38.68, 51.69);
    			vertex(37.38, 55.59);
    			vertex(61.97, 71.54);
    			vertex(63.03, 69.43);
    			vertex(63.78, 67.09);
    			vertex(64.39, 65.11);
    		endpolygon();

    #	Paper
    		bgnpolygon();
    			vertex(36.28, 58.09);
    			vertex(33.81, 60.69);
    			vertex(56.92, 75.75);
    			vertex(59.97, 73.64);
    		endpolygon();

    #	Paper
    		bgnpolygon();
    			vertex(33.81, 60.69);
    			vertex(30.72, 62.75);
    			vertex(48.78, 76.84);
    			vertex(50.72, 76.98);
    			vertex(53.78, 76.84);
    			vertex(56.92, 75.75);
    		endpolygon();

    #	Paper
    		bgnpolygon();
    			vertex(30.72, 62.75);
    			vertex(27.32, 63.68);
    			vertex(23.78, 64.34);
    			vertex(48.78, 76.84);
    		endpolygon();

    #	Paper
    		bgnpolygon();
    			vertex(37.38, 55.59);
    			vertex(36.28, 58.09);
    			vertex(59.97, 73.64);
    			vertex(61.97, 71.54);
    		endpolygon();

    #	Paper
    		color(outlinecolor);
    		bgnclosedline();
    			vertex(65.48, 56.49);
    			vertex(40.28, 43.84);
    			vertex(39.78, 47.79);
    			vertex(38.68, 51.69);
    			vertex(37.38, 55.59);
    			vertex(36.28, 58.09);
    			vertex(33.81, 60.69);
    			vertex(30.72, 62.75);
    			vertex(27.32, 63.68);
    			vertex(23.78, 64.34);
    			vertex(48.78, 76.84);
    			vertex(50.72, 76.98);
    			vertex(53.78, 76.84);
    			vertex(56.92, 75.75);
    			vertex(59.97, 73.64);
    			vertex(61.97, 71.54);
    			vertex(63.03, 69.43);
    			vertex(63.78, 67.09);
    			vertex(64.39, 65.11);
    			vertex(64.68, 63.09);
    			vertex(65.03, 61.43);
    			vertex(65.22, 58.87);
    		endclosedline();
            }
}

generic.script [::poFti]poFti, Top

Returns the string description of icon generic.script.

generic.script
Return value

Returns the string description of icon generic.script.

proc ::poFti::generic.script {} {

            # Returns the string description of icon `generic.script`.

            return {
    #	Script
    		color(iconcolor);
    		bgnoutlinepolygon();
    			vertex(50.40, 20.30);
    			vertex(23.90, 33.10);
    			vertex(22.50, 34.20);
    			vertex(21.10, 35.20);
    			vertex(19.60, 36.70);
    			vertex(18.60, 37.90);
    			vertex(17.50, 39.50);
    			vertex(16.90, 41.90);
    			vertex(16.90, 56.60);
    			vertex(53.10, 74.10);
    			vertex(53.10, 59.50);
    			vertex(53.60, 57.70);
    			vertex(54.80, 55.90);
    			vertex(56.00, 54.50);
    			vertex(57.30, 53.60);
    			vertex(58.80, 52.60);
    			vertex(60.40, 51.30);
    			vertex(86.50, 38.50);
    		endoutlinepolygon(outlinecolor);

    #	Text Lines
    		color(outlinecolor);
    		bgnline();
    			vertex(25.10, 52.50);
    			vertex(47.30, 63.00);
    		endline();

    #	Path_2
    		bgnline();
    			vertex(28.90, 48.40);
    			vertex(47.20, 57.10);
    		endline();

    #	Path_3
    		bgnline();
    			vertex(25.40, 41.00);
    			vertex(45.00, 50.30);
    		endline();

    #	Path_4
    		bgnline();
    			vertex(33.20, 38.60);
    			vertex(52.80, 48.30);
    		endline();

    #	Path_5
    		bgnline();
    			vertex(40.30, 36.40);
    			vertex(58.70, 45.30);
    		endline();

    #	Path_6
    		bgnline();
    			vertex(46.30, 33.20);
    			vertex(64.90, 42.40);
    		endline();

    #	Path_7
    		bgnline();
    			vertex(48.30, 28.20);
    			vertex(70.80, 39.30);
    		endline();
            }
}

GetColorNumFromRgb [::poFti]poFti, Top

Get color number from RGB color values.

GetColorNumFromRgb r g b
Parameters
rRed color.
gGreen color.
bBlue color.
Description

Color values are specified in the range [0 .. 255] and the best matching color number is choosen.

Return value

Returns best matching color number.

proc ::poFti::GetColorNumFromRgb {r g b} {

    # Get color number from RGB color values.
    #
    # r - Red color.
    # g - Green color.
    # b - Blue color.
    #
    # Color values are specified in the range \[0 .. 255\]
    # and the best matching color number is choosen.
    #
    # Returns best matching color number.

    set average  500
    set colorNum 0

    foreach fti [array names ::poFti::sColorMap] {
        set rgb [::poFti::GetRgbFromColorNum $fti]
        set cur [expr {abs([lindex $rgb 0] - $r) +  abs([lindex $rgb 1] - $g) +  abs([lindex $rgb 2] - $b) }]
        if { $cur < $average } {
            set average  $cur
            set colorNum $fti
        }
    }
    return $colorNum
}

GetColorNumFromRgbString [::poFti]poFti, Top

Get color number from hexadecimal color string.

GetColorNumFromRgbString rgbString
Parameters
rgbStringColor as hexadecimal string.
Description

Color values are specified in format #RRGGBB and the best matching color number is choosen.

Return value

Returns best matching color number.

proc ::poFti::GetColorNumFromRgbString {rgbString} {

    # Get color number from hexadecimal color string.
    #
    # rgbString - Color as hexadecimal string.
    #
    # Color values are specified in format `#RRGGBB`
    # and the best matching color number is choosen.
    #
    # Returns best matching color number.

    set rgbList [::poFti::GetRgbFromFromRgbString $rgbString]
    return [::poFti::GetColorNumFromRgb {*}$rgbList]
}

GetPointSize [::poFti]poFti, Top

Get the size of a point.

GetPointSize
Return value

Returns the size of an item of type point in pixels, when drawn in a canvas.

See also

Item::Draw, Item::SetType

proc ::poFti::GetPointSize {} {

    # Get the size of a point.
    #
    # Returns the size of an item of type `point` in pixels,
    # when drawn in a canvas.
    #
    # See also: Item::Draw Item::SetType

    return $::poFti::sPointSize
}

GetRgbFromColor [::poFti]poFti, Top

Get RGB color values from color.

GetRgbFromColor color
Parameters
colorColor number or string.
Description

Convert a color number or special color into RGB values.

Return value

Returns list of [R G B] values.

proc ::poFti::GetRgbFromColor {color} {

    # Get RGB color values from color.
    #
    # color - Color number or string.
    #
    # Convert a color number or special color into RGB values.
    #
    # Returns list of \[R G B\] values.

    if { $color eq "iconcolor" } {
        set colorNum 7  ; # White
    } elseif { $color eq "shadowcolor" } {
        set colorNum -67 ; # Grey
    } elseif { $color eq "outlinecolor" } {
        set colorNum 0  ; # Black
    } else {
        set colorNum $color
    }
    return [::poFti::GetRgbFromColorNum $colorNum]
}

GetRgbFromColorNum [::poFti]poFti, Top

Get RGB color values from color number.

GetRgbFromColorNum colorNum
Parameters
colorNumColor number.
Description

Convert a color number into RGB values.

Return value

Returns list of [R G B] values. If $colorNum is not a valid color number, [0 0 0] is returned.

proc ::poFti::GetRgbFromColorNum {colorNum} {

    # Get RGB color values from color number.
    #
    # colorNum - Color number.
    #
    # Convert a color number into RGB values.
    #
    # Returns list of \[R G B\] values.
    # If $colorNum is not a valid color number, \[0 0 0\] is returned.

    if { [info exist ::poFti::sColorMap($colorNum)  ] } {
        return $::poFti::sColorMap($colorNum)
    }
    return {0 0 0}
}

GetRgbFromFromRgbString [::poFti]poFti, Top

Get RGB color values from hexadecimal color value.

GetRgbFromFromRgbString rgbString
Parameters
rgbStringColor as hexadecimal string.
Description

Convert a hexadecimal color value into RGB values.

Return value

Returns list of [R G B] values.

proc ::poFti::GetRgbFromFromRgbString {rgbString} {

    # Get RGB color values from hexadecimal color value.
    #
    # rgbString - Color as hexadecimal string.
    #
    # Convert a hexadecimal color value into RGB values.
    #
    # Returns list of \[R G B\] values.

    if { 3 != [scan $rgbString "#%02x%02x%02x" r g b] } {
        error "Invalid color string \"$rgbString\" specified."
    }
    return [list $r $g $b]
}

GetRgbStringFromColor [::poFti]poFti, Top

Get hexadecimal color string from color.

GetRgbStringFromColor color
Parameters
colorColor number or special string.
Description

Convert a color number or special color into hexadecimal color string.

Return value

Returns hexadecimal color string in format #RRGGBB.

proc ::poFti::GetRgbStringFromColor {color} {

    # Get hexadecimal color string from color.
    #
    # color - Color number or special string.
    #
    # Convert a color number or special color into hexadecimal color string.
    #
    # Returns hexadecimal color string in format `#RRGGBB`.

    return [GetRgbStringFromRgb {*}[GetRgbFromColor $color]]
}

GetRgbStringFromRgb [::poFti]poFti, Top

Get hexadecimal color from RGB color values.

GetRgbStringFromRgb r g b
Parameters
rRed color.
gGreen color.
bBlue color.
Description

Color values are specified in the range [0 .. 255].

Return value

Returns hexadecimal color string in format #RRGGBB.

proc ::poFti::GetRgbStringFromRgb {r g b} {

    # Get hexadecimal color from RGB color values.
    #
    # r - Red color.
    # g - Green color.
    # b - Blue color.
    #
    # Color values are specified in the range \[0 .. 255\].
    #
    # Returns hexadecimal color string in format `#RRGGBB`.

    return [format "#%02x%02x%02x" $r $g $b]
}

GetSpecialColorNum [::poFti]poFti, Top

Get color number of special color.

GetSpecialColorNum color
Parameters
colorSpecial color name.
Description

If $color is not a valid special color name, an error is thrown.

Return value

Returns numeric color number of $color.

See also

GetSpecialColors, IsSpecialColor, Item::GetColor

proc ::poFti::GetSpecialColorNum {color} {

    # Get color number of special color.
    #
    # color - Special color name.
    #
    # Returns numeric color number of $color.
    #
    # If $color is not a valid special color name,
    # an error is thrown.
    #
    # See also: GetSpecialColors IsSpecialColor Item::GetColor

    foreach { name value } [GetSpecialColors] {
        if { $color eq $name } {
            return $value
        }
    }
    error "Invalid color \"$color\" specified."
}

GetSpecialColors [::poFti]poFti, Top

Get the names and color numbers of special colors.

GetSpecialColors
Return value

Returns a list of the names and color numbers of FTI specific color names.

See also

IsSpecialColor, GetSpecialColorNum, Item::GetColor

proc ::poFti::GetSpecialColors {} {

    # Get the names and color numbers of special colors.
    #
    # Returns a list of the names and color numbers of
    # FTI specific color names.
    #
    # See also: IsSpecialColor GetSpecialColorNum Item::GetColor

    return [list "iconcolor" 7 "shadowcolor" -67 "outlinecolor" 0]
}

GetTypeNames [::poFti]poFti, Top

Get the names of valid item types.

GetTypeNames
Return value

Returns a list of valid item type names.

See also

Item::GetType, Item::SetType

proc ::poFti::GetTypeNames {} {

    # Get the names of valid item types.
    #
    # Returns a list of valid item type names.
    #
    # See also: Item::GetType Item::SetType

    return [list "closedline" "line" "polygon" "outlinepolygon" "point"]
}

IsSpecialColor [::poFti]poFti, Top

Check, if supplied color is a special color.

IsSpecialColor color
Parameters
colorColor number or string.
Return value

Returns true, if $color is a special color name, otherwise false.

See also

GetSpecialColors, GetSpecialColorNum, Item::GetColor

proc ::poFti::IsSpecialColor {color} {

    # Check, if supplied color is a special color.
    #
    # color - Color number or string.
    #
    # Returns true, if $color is a special color name,
    # otherwise false.
    #
    # See also: GetSpecialColors GetSpecialColorNum Item::GetColor

    foreach { name value } [GetSpecialColors] {
        if { $color eq $name } {
            return true
        }
    }
    return false
}

ClassespoFti, Top

Icon [::poFti]poFti, Top

Method summary
constructorConstructor for the class.
destructorDestructor for the class.
AddItemAdd an item to the icon.
AsPhotoGet the icon displayed in the Tk canvas as a photo image.
DrawDraw the icon into a Tk canvas.
FlipFlip the icon vertically or horizontally.
GetItemGet an item of the icon.
GetNameGet the name of the icon.
GetNumItemsGet the number of items of the icon.
ReadRead an icon file.
ReadFromStringRead icon data from string.
RotateRotate the icon around specified center.
ScaleScale the icon using specified center.
SetNameSet the name of the icon.
WriteWrite a icon file.
WriteToImageFileWrite the icon displayed in the Tk canvas to an image file.

constructor [::poFti::Icon]Icon, Top

Icon create OBJNAME
Icon new
method constructor {} {

    set sName "Unnamed"
    set sItemList [list]
}

destructor [::poFti::Icon]Icon, Top

ICONOBJ destroy
method destructor {} {

}

AddItem [::poFti::Icon]Icon, Top

Add an item to the icon.

ICONOBJ AddItem itemObj
Parameters
itemObjObject identifier of the item.
See also

GetItem, GetNumItems

method AddItem {itemObj} {

    # Add an item to the icon.
    #
    # itemObj - Object identifier of the item.
    #
    # See also: GetItem GetNumItems

    lappend sItemList $itemObj
}

AsPhoto [::poFti::Icon]Icon, Top

Get the icon displayed in the Tk canvas as a photo image.

ICONOBJ AsPhoto canvasId
Parameters
canvasIdIdentifier of the canvas.
Description

If the Img extension is not available, an error is thrown.

Return value

Returns the photo image. The photo image must be deleted by the caller.

See also

Read, Write, Draw, WriteToImageFile

method AsPhoto {canvasId} {

    # Get the icon displayed in the Tk canvas as a photo image.
    #
    # canvasId - Identifier of the canvas.
    #
    # Returns the photo image.
    # The photo image must be deleted by the caller.
    #
    # If the `Img` extension is not available, an error is thrown.
    #
    # See also: Read Write Draw WriteToImageFile

    set retVal [catch {package require Img} version]
    if { $retVal != 0 } {
        error "Method AsPhoto needs the Img extension."
    }
    set region [$canvasId cget -scrollregion]
    if { [llength $region] == 0 } {
        set xsize [$canvasId cget -width]
        set ysize [$canvasId cget -height]
    } else {
        set xsize [lindex $region 2]
        set ysize [lindex $region 3]
    }
    set img [image create photo -width $xsize -height $ysize]

    $canvasId xview moveto 0
    $canvasId yview moveto 0
    update idletasks
    set xr 0.0
    set yr 0.0
    set px 0
    set py 0
    while { $xr < 1.0 } {
        while { $yr < 1.0 } {
            set tmpImg [image create photo -format window -data $canvasId]
            $img copy $tmpImg -to $px $py
            image delete $tmpImg
            set yr [lindex [$canvasId yview] 1]
            $canvasId yview moveto $yr
            set py [expr round ($ysize * [lindex [$canvasId yview] 0])]
            update idletasks
        }
        $canvasId yview moveto 0
        set yr 0.0
        set py 0

        set xr [lindex [$canvasId xview] 1]
        $canvasId xview moveto $xr
        set px [expr round ($xsize * [lindex [$canvasId xview] 0])]
        update idletasks
    }
    return $img
}

Draw [::poFti::Icon]Icon, Top

Draw the icon into a Tk canvas.

ICONOBJ Draw canvasId ?args?
Parameters
canvasIdIdentifier of the canvas.
argsOptions described below.
-height <int>Height of the drawn icon in pixel.
-tag <string>Assign canvas tag name to all items. Default: "FtiIcon".
-width <int>Width of the drawn icon in pixel.
Description

Each item of the icon is assigned 4 canvas tags:

  1. Fixed value: FtiIcon.
  2. Tag supplied with option -tag.
  3. Item name.
  4. Item type.

If -width or -height is not specified, the width or height of the canvas is used.

See also

Read, Write, AsPhoto, WriteToImageFile, ::poFti::DrawGrid, ::poFti::GetTypeNames

method Draw {canvasId args} {

    # Draw the icon into a Tk canvas.
    #
    # canvasId - Identifier of the canvas.
    # args     - Options described below.
    #
    # -width <int>  - Width of the drawn icon in pixel.
    # -height <int> - Height of the drawn icon in pixel.
    # -tag <string> - Assign canvas tag name to all items.
    #                 Default: "FtiIcon".
    #
    # Each item of the icon is assigned 4 canvas tags:
    # 1. Fixed value: `FtiIcon`.
    # 2. Tag supplied with option `-tag`.
    # 3. Item name.
    # 4. Item type.
    #
    # If `-width` or `-height` is not specified, the
    # width or height of the canvas is used.
    #
    # See also: Read Write AsPhoto WriteToImageFile ::poFti::DrawGrid ::poFti::GetTypeNames

    set opts [dict create  -width  0  -height 0  -tag    "FtiIcon"
    ]
    foreach { key value } $args {
        if { [dict exists $opts $key] } {
            if { $value eq "" } {
                error "Draw: No value specified for key \"$key\"."
            }
            dict set opts $key $value
        } else {
            error "Draw: Unknown option \"$key\" specified."
        }
    }

    set width  [dict get $opts "-width"]
    set height [dict get $opts "-height"]
    if { $width <= 0 } {
        set width [$canvasId cget -width]
    }
    if { $height <= 0 } {
        set height [$canvasId cget -height]
    }
    foreach itemObj $sItemList {
        $itemObj Draw $canvasId $width $height [dict get $opts "-tag"]
    }
    update
}

Flip [::poFti::Icon]Icon, Top

Flip the icon vertically or horizontally.

ICONOBJ Flip direction
Parameters
directionFlip direction as string. Possible values: horior vert.
Description

If $direction is an invalid string, an error is thrown.

See also

Read, Write, Draw, Rotate, Scale

method Flip {direction} {

    # Flip the icon vertically or horizontally.
    #
    # direction - Flip direction as string.
    #             Possible values: `hori`or `vert`.
    #
    # If $direction is an invalid string, an error is thrown.
    #
    # See also: Read Write Draw Rotate Scale

    if { $direction ne "hori" && $direction ne "vert" } {
        error "Invalid flip direction \"$direction\" specified."
    }
    foreach itemObj $sItemList {
        $itemObj Flip $direction
    }
}

GetItem [::poFti::Icon]Icon, Top

Get an item of the icon.

ICONOBJ GetItem itemInd
Parameters
itemIndItem index.
Return value

Returns the item object stored at index $itemInd. If $itemInd is out of bounds or the icon has no items, an error is thrown.

See also

AddItem, GetNumItems

method GetItem {itemInd} {

    # Get an item of the icon.
    #
    # itemInd - Item index.
    #
    # Returns the item object stored at index $itemInd.
    # If $itemInd is out of bounds or the icon has no items,
    # an error is thrown.
    #
    # See also: AddItem GetNumItems

    if { [llength $sItemList] == 0 } {
        error "Icon \"[my GetName]\" has no items."
    }
    if { $itemInd < 0 || $itemInd >= [llength $sItemList] } {
        error "Item index $itemInd not in range \[0 ..[llength $sItemList]\]."
    }
    return [lindex $sItemList $itemInd]
}

GetName [::poFti::Icon]Icon, Top

Get the name of the icon.

ICONOBJ GetName
Return value

Returns the icon name.

See also

SetName, Read

method GetName {} {

    # Get the name of the icon.
    #
    # Returns the icon name.
    #
    # See also: SetName Read

    return $sName
}

GetNumItems [::poFti::Icon]Icon, Top

Get the number of items of the icon.

ICONOBJ GetNumItems ?type?
Parameters
typeItem type. Optional, default "".
Description

If $type is specified and a valid item type, only items of the specified type are counted. Otherwise the number of all items are counted.

Return value

Returns the number of items of the icon.

See also

AddItem, ::poFti::GetTypeNames

method GetNumItems {{type {}}} {

    # Get the number of items of the icon.
    #
    # type - Item type.
    #
    # If $type is specified and a valid item type,
    # only items of the specified type are counted.
    # Otherwise the number of all items are counted.
    #
    # Returns the number of items of the icon.
    #
    # See also: AddItem ::poFti::GetTypeNames

    if { $type eq "" } {
        return [llength $sItemList]
    } else {
        set count 0
        foreach item $sItemList {
            if { [$item GetType] eq $type } {
                incr count
            }
        }
        return $count
    }
}

Read [::poFti::Icon]Icon, Top

Read an icon file.

ICONOBJ Read fileName
Parameters
fileNameName of the FTI file.
Return value

Returns the object identifier of the new Icon. If the file could not be openend or has invalid content, an error is thrown.

See also

ReadFromString, Write, Draw, AsPhoto, WriteToImageFile

method Read {fileName} {

    # Read an icon file.
    #
    # fileName - Name of the FTI file.
    #
    # Returns the object identifier of the new Icon.
    # If the file could not be openend or has invalid
    # content, an error is thrown.
    #
    # See also: ReadFromString Write Draw AsPhoto WriteToImageFile

    set retVal [catch {open $fileName "r"} fp]
    if { $retVal != 0 } {
        error "Could not open file \"$fileName\" for reading."
    }
    set fp [open $fileName "r"]
    set iconData [read $fp]
    close $fp

    return [my ReadFromString $iconData [file rootname [file tail $fileName]]]
}

ReadFromString [::poFti::Icon]Icon, Top

Read icon data from string.

ICONOBJ ReadFromString iconString ?iconName?
Parameters
iconStringString containing the icon data.
iconNameIcon name. Optional, default "".
Return value

Returns the object identifier of the new Icon. If the string has invalid content, an error is thrown.

See also

Read, Write, Draw, AsPhoto, WriteToImageFile

method ReadFromString {iconString {iconName {}}} {

    # Read icon data from string.
    #
    # iconString - String containing the icon data.
    # iconName   - Icon name.
    #
    # Returns the object identifier of the new Icon.
    # If the string has invalid content, an error is thrown.
    #
    # See also: Read Write Draw AsPhoto WriteToImageFile

    foreach line [split $iconString "\n"] {
        if { [string trim $line] eq "" } {
            continue
        }
        if { [string index $line 0] eq "#" } {
            set itemName [string trim [string range $line 1 end]]
            set newItem [poFti Item new $itemName]
        } else {
            set cmdLine [string trim $line]
            if { [string first "(" $cmdLine] < 0 } {
                error "Unsupported command \"$cmdLine\"."
            }
            set cmdList [split $cmdLine "("]
            set cmdName [lindex $cmdList 0]
            set cmdParam [lindex $cmdList 1]
            set cmdParam [string trimright $cmdParam ");"]
            set params [list]
            if { $cmdParam ne "" } {
                foreach param [split $cmdParam ","] {
                    lappend params [string trim $param]
                }
            }
            switch -exact -- $cmdName {
                "bgnclosedline" {
                    $newItem SetType "closedline"
                }
                "bgnline" {
                    $newItem SetType "line"
                }
                "bgnoutlinepolygon" {
                    $newItem SetType "outlinepolygon"
                }
                "bgnpoint" {
                    $newItem SetType "point"
                }
                "bgnpolygon" {
                    $newItem SetType "polygon"
                }
                "color" {
                    $newItem SetColor $cmdParam
                }
                "endclosedline" {
                    my AddItem $newItem
                }
                "endline" {
                    my AddItem $newItem
                }
                "endoutlinepolygon" {
                    $newItem SetOutlineColor $cmdParam
                    my AddItem $newItem
                }
                "endpoint" {
                    my AddItem $newItem
                }
                "endpolygon" {
                    my AddItem $newItem
                }
                "vertex" {
                    $newItem AddVertex [lindex $params 0] [lindex $params 1]
                }
                default {
                    error "Unsupported command \"$cmdName\"."
                }
            }
        }
    }
    my SetName $iconName

    # Consistency checks.
    if { [my GetNumItems] == 0 } {
        error "Icon \"[my GetName]\" has no items."
    }
    foreach itemObj $sItemList {
        set itemType [$itemObj GetType]
        switch -exact -- $itemType {
            "point" {
                set numVtx 1
            }
            "line" {
                set numVtx 2
            }
            "closedline" -
            "polygon" -
            "outlinepolygon" {
                set numVtx 3
            }
            default {
                error "Item \"[$itemObj GetName]\" has invalid type \"itemType\"."
           }
        }
        if { [$itemObj GetNumVertices] < $numVtx } {
            error "Item \"[$itemObj GetName]\" has invalid number of vertices ([$itemObj GetNumVertices])."
        }
    }
}

Rotate [::poFti::Icon]Icon, Top

Rotate the icon around specified center.

ICONOBJ Rotate angleDeg ?cx? ?cy?
Parameters
angleDegRotation angle in degrees. Rotation occurs counterclockwise.
cxX coordinate of rotation center. Optional, default 0.0.
cyY coordinate of rotation center. Optional, default 0.0.
See also

Read, Write, Draw, Flip, Scale

method Rotate {angleDeg {cx 0.0} {cy 0.0}} {

    # Rotate the icon around specified center.
    #
    # angleDeg - Rotation angle in degrees.
    #            Rotation occurs counterclockwise.
    # cx       - X coordinate of rotation center.
    # cy       - Y coordinate of rotation center.
    #
    # See also: Read Write Draw Flip Scale

    foreach itemObj $sItemList {
        $itemObj Rotate $angleDeg $cx $cy
    }
}

Scale [::poFti::Icon]Icon, Top

Scale the icon using specified center.

ICONOBJ Scale sx sy ?cx? ?cy?
Parameters
sxX scale factor.
syY scale factor.
cxX coordinate of scale center. Optional, default 0.0.
cyY coordinate of scale center. Optional, default 0.0.
See also

Read, Write, Draw, Flip, Rotate

method Scale {sx sy {cx 0.0} {cy 0.0}} {

    # Scale the icon using specified center.
    #
    # sx - X scale factor.
    # sy - Y scale factor.
    # cx - X coordinate of scale center.
    # cy - Y coordinate of scale center.
    #
    # See also: Read Write Draw Flip Rotate

    foreach itemObj $sItemList {
        $itemObj Scale $sx $sy $cx $cy
    }
}

SetName [::poFti::Icon]Icon, Top

Set the name of the icon.

ICONOBJ SetName name
Parameters
nameIcon name.
See also

GetName, constructor, Read

method SetName {name} {

    # Set the name of the icon.
    #
    # name - Icon name.
    #
    # See also: GetName constructor Read

    set sName $name
}

Write [::poFti::Icon]Icon, Top

Write a icon file.

ICONOBJ Write fileName
Parameters
fileNameName of the FTI file.
Description

If the file could not be openend, an error is thrown.

See also

Read, Draw, AsPhoto, WriteToImageFile

method Write {fileName} {

    # Write a icon file.
    #
    # fileName - Name of the FTI file.
    #
    # If the file could not be openend,
    # an error is thrown.
    #
    # See also: Read Draw AsPhoto WriteToImageFile

    set retVal [catch {open $fileName "w"} fp]
    if { $retVal != 0 } {
        error "Could not open file \"$fileName\" for writing."
    }
    fconfigure $fp -translation lf
    set ::poFti::sLastColorNumWritten 1000
    foreach itemObj $sItemList {
        $itemObj Write $fp
    }
    close $fp
}

WriteToImageFile [::poFti::Icon]Icon, Top

Write the icon displayed in the Tk canvas to an image file.

ICONOBJ WriteToImageFile canvasId fileName ?format?
Parameters
canvasIdIdentifier of the canvas.
fileNameName of the image file.
formatOutput format of the image file. Optional, default PNG.
Description

Valid format strings are: BMP GIF JPEG PCX PNG PPM SGI SUN TGA TIFF XPM

If the Img extension is not available, an error is thrown.

See also

Read, Write, Draw, AsPhoto

method WriteToImageFile {canvasId fileName {format PNG}} {

    # Write the icon displayed in the Tk canvas to an image file.
    #
    # canvasId - Identifier of the canvas.
    # fileName - Name of the image file.
    # format   - Output format of the image file.
    #
    # Valid format strings are: `BMP GIF JPEG PCX PNG PPM SGI SUN TGA TIFF XPM`
    #
    # If the `Img` extension is not available, an error is thrown.
    #
    # See also: Read Write Draw AsPhoto

    set retVal [catch {package require Img} version]
    if { $retVal != 0 } {
        error "Method WriteToImageFile needs the Img extension."
    }
    set phImg [my AsPhoto $canvasId]
    $phImg write $fileName -format $format
    image delete $phImg
}

Item [::poFti]poFti, Top

Method summary
constructorConstructor for the class.
destructorDestructor for the class.
AddVertexAdd a vertex to the item object.
AddVerticesAdd vertices to the item object.
DrawDraw the item into a Tk canvas.
FlipFlip the item vertically or horizontally.
GetColorGet the color of the item.
GetNameGet the name of the item.
GetNumVerticesGet the number of vertices of the item.
GetOutlineColorGet the outline color of the item.
GetTypeGet the type of the item.
GetVertexGet the coordinates of a vertex.
GetVerticesGet the coordinates of all vertices.
RotateRotate the item around specified center.
ScaleScale the item using specified center.
SetColorSet the color of the item.
SetColorRgbSet the color of the item.
SetColorRgbStringSet the color of the item.
SetNameSet the name of the item.
SetOutlineColorSet the outline color of the item.
SetOutlineColorRgbSet the outline color of the item.
SetOutlineColorRgbStringSet the outline color of the item.
SetTypeSet the type of the item.
WriteWrite the item to file.

constructor [::poFti::Item]Item, Top

Create an item object.

Item create OBJNAME name ?type?
Item new name ?type?
Parameters
nameItem name.
typeItem type. Optional, default line.
See also

SetName, SetType

method constructor {name {type line}} {

    # Create an item object.
    #
    # name - Item name.
    # type - Item type.
    #
    # See also: SetName SetType

    if { $type ni [poFti::GetTypeNames] } {
        error "Invalid type \"$type\" specified."
    }
    set sName            $name
    set sType            $type
    set sColorNum        $::poFti::sCurColorNum
    set sOutlineColorNum $::poFti::sCurColorNum
    set sCoordList       [list]
}

destructor [::poFti::Item]Item, Top

ITEMOBJ destroy
method destructor {} {

    unset sName
    unset sType
    unset sColorNum
    unset sOutlineColorNum
    unset sCoordList
}

AddVertex [::poFti::Item]Item, Top

Add a vertex to the item object.

ITEMOBJ AddVertex x y
Parameters
xX coordinate of the vertex.
yY coordinate of the vertex.
See also

AddVertices, GetNumVertices

method AddVertex {x y} {

    # Add a vertex to the item object.
    #
    # x - X coordinate of the vertex.
    # y - Y coordinate of the vertex.
    #
    # See also: AddVertices GetNumVertices

    lappend sCoordList $x $y
}

AddVertices [::poFti::Item]Item, Top

Add vertices to the item object.

ITEMOBJ AddVertices ?args?
Parameters
argsList of x, y coordinates.
Description

If the number of coordinates is not a multiple of two, an error is thrown.

See also

AddVertex, GetNumVertices

method AddVertices {args} {

    # Add vertices to the item object.
    #
    # args - List of x, y coordinates.
    #
    # If the number of coordinates is not a multiple
    # of two, an error is thrown.
    #
    # See also: AddVertex GetNumVertices

    if { [llength $args] % 2 != 0 } {
        error "Invalid number of coordinates."
    }

    foreach vtx $args {
        lappend sCoordList $vtx
    }
}

Draw [::poFti::Item]Item, Top

Draw the item into a Tk canvas.

ITEMOBJ Draw canvasId width height tag
Parameters
canvasIdIdentifier of the canvas.
widthWidth of the drawn icon in pixel.
heightHeight of the drawn icon in pixel.
tagCanvas tag name assigned to the item.
Description

This method is typically only used by the Draw method of class Icon.

Return value

Returns the canvas item id.

See also

Icon::Draw

method Draw {canvasId width height tag} {

    # Draw the item into a Tk canvas.
    #
    # canvasId - Identifier of the canvas.
    # width    - Width of the drawn icon in pixel.
    # height   - Height of the drawn icon in pixel.
    # tag      - Canvas tag name assigned to the item.
    #
    # This method is typically only used by the `Draw`
    # method of class `Icon`.
    #
    # Returns the canvas item id.
    #
    # See also: Icon::Draw

    if { [llength $sCoordList] == 0 } {
        error "Item has no vertices."
    }
    set fillColor [poFti GetRgbStringFromColor $sColorNum]
    set coords [list]
    foreach { x y } $sCoordList {
        set cx [expr { $x * 0.01 * $width }]
        set cy [expr { $height - ($y * 0.01 * $height) }]
        lappend coords $cx $cy
    }
    if { $sType eq "closedline" } {
        set cx [lindex $coords 0]
        set cy [lindex $coords 1]
        lappend coords $cx $cy
    }
    if { $sType eq "line" } {
        set itemId [$canvasId create line $coords  -fill $fillColor -width $::poFti::sPointSize  -tags [list "FtiIcon" "$tag" "[my GetName]" "line" $sColorNum]]
    } elseif { $sType eq "closedline" } {
        set itemId [$canvasId create line $coords  -fill $fillColor -width $::poFti::sPointSize  -tags [list "FtiIcon" "$tag" "[my GetName]" "closedline" $sColorNum]]
    } elseif { $sType eq "polygon" } {
        set itemId [$canvasId create polygon $coords  -fill $fillColor -outline $fillColor  -tags [list "FtiIcon" "$tag" "[my GetName]" "polygon" $sColorNum]]
    } elseif { $sType eq "outlinepolygon" } {
        set outlineColor [::poFti::GetRgbStringFromRgb {*}[::poFti::GetRgbFromColor $sOutlineColorNum]]
        set itemId [$canvasId create polygon $coords  -fill $fillColor -outline $outlineColor -width $::poFti::sPointSize  -tags [list "FtiIcon" "$tag" "[my GetName]"  "outlinepolygon" $sColorNum $sOutlineColorNum]]
    } elseif { $sType eq "point" } {
        lassign $coords x y
        set psHalf [expr {$::poFti::sPointSize / 2 }]
        set x1 [expr { $x - $psHalf }]
        set y1 [expr { $y - $psHalf }]
        set x2 [expr { $x + $psHalf }]
        set y2 [expr { $y + $psHalf }]
        set itemId [$canvasId create rect $x1 $y1 $x2 $y2  -fill $fillColor -outline $fillColor  -tags [list "FtiIcon" "$tag" "[my GetName]" "point" $sColorNum]]
    }
    return $itemId
}

Flip [::poFti::Item]Item, Top

Flip the item vertically or horizontally.

ITEMOBJ Flip direction
Parameters
directionFlip direction as string. Possible values: horior vert.
Description

This method is typically only used by the Flip method of class Icon.

See also

Icon::Flip

method Flip {direction} {

    # Flip the item vertically or horizontally.
    #
    # direction - Flip direction as string.
    #             Possible values: `hori`or `vert`.
    #
    # This method is typically only used by the `Flip`
    # method of class `Icon`.
    #
    # See also: Icon::Flip

    set coords [list]
    foreach { x y } $sCoordList {
        set fx $x
        if { $direction eq "hori" } {
            set fx [expr { 100 - $x }]
        }
        set fy $y
        if { $direction eq "vert" } {
            set fy [expr { 100 - $y }]
        }
        lappend coords $fx $fy
    }
    set sCoordList $coords
}

GetColor [::poFti::Item]Item, Top

Get the color of the item.

ITEMOBJ GetColor
Return value

Returns the color number or special color of the item.

See also

SetColor, SetColorRgb, SetOutlineColor, SetOutlineColorRgb, GetOutlineColor

method GetColor {} {

    # Get the color of the item.
    #
    # Returns the color number or special color of the item.
    #
    # See also: SetColor SetColorRgb SetOutlineColor SetOutlineColorRgb GetOutlineColor

    return $sColorNum
}

GetName [::poFti::Item]Item, Top

Get the name of the item.

ITEMOBJ GetName
Return value

Returns the item name.

See also

SetName

method GetName {} {

    # Get the name of the item.
    #
    # Returns the item name.
    #
    # See also: SetName

    return $sName
}

GetNumVertices [::poFti::Item]Item, Top

Get the number of vertices of the item.

ITEMOBJ GetNumVertices
Return value

Returns the number of vertices.

See also

AddVertex, AddVertices

method GetNumVertices {} {

    # Get the number of vertices of the item.
    #
    # Returns the number of vertices.
    #
    # See also: AddVertex AddVertices

    return [expr {[llength $sCoordList] / 2 }]
}

GetOutlineColor [::poFti::Item]Item, Top

Get the outline color of the item.

ITEMOBJ GetOutlineColor
Return value

Returns the outline color of the item.

See also

SetColor, SetColorRgb, SetOutlineColor, SetOutlineColorRgb

method GetOutlineColor {} {

    # Get the outline color of the item.
    #
    # Returns the outline color of the item.
    #
    # See also: SetColor SetColorRgb SetOutlineColor SetOutlineColorRgb

    return $sOutlineColorNum
}

GetType [::poFti::Item]Item, Top

Get the type of the item.

ITEMOBJ GetType
Return value

Returns the item type name.

See also

::poFti::GetTypeNames, SetType

method GetType {} {

    # Get the type of the item.
    #
    # Returns the item type name.
    #
    # See also: ::poFti::GetTypeNames SetType

    return $sType
}

GetVertex [::poFti::Item]Item, Top

Get the coordinates of a vertex.

ITEMOBJ GetVertex vertexInd
Parameters
vertexIndVertex index.
Return value

Returns the coordinates of vertex stored at index $vertexInd as a list with two components. If $vertexInd is out of bounds or the item has no vertices, an error is thrown.

See also

AddVertex, GetVertices, GetNumVertices

method GetVertex {vertexInd} {

    # Get the coordinates of a vertex.
    #
    # vertexInd - Vertex index.
    #
    # Returns the coordinates of vertex stored at index $vertexInd
    # as a list with two components.
    # If $vertexInd is out of bounds or the item has no vertices,
    # an error is thrown.
    #
    # See also: AddVertex GetVertices GetNumVertices

    if { [llength $sCoordList] == 0 } {
        error "Item \"[my GetName]\" has no vertices."
    }
    if { $vertexInd < 0 || $vertexInd >= [llength $sCoordList] } {
        error "Vertex index $vertexInd not in range \[0 ..[llength $sCoordList]\]."
    }
    return [lrange $sCoordList $vertexInd [expr { $vertexInd + 1 }]]
}

GetVertices [::poFti::Item]Item, Top

Get the coordinates of all vertices.

ITEMOBJ GetVertices
Return value

Returns the coordinates of all vertices of the item as a list.

See also

AddVertex, GetVertex, GetNumVertices

method GetVertices {} {

    # Get the coordinates of all vertices.
    #
    # Returns the coordinates of all vertices of the item
    # as a list.
    #
    # See also: AddVertex GetVertex GetNumVertices

    return $sCoordList
}

Rotate [::poFti::Item]Item, Top

Rotate the item around specified center.

ITEMOBJ Rotate angleDeg ?cx? ?cy?
Parameters
angleDegRotation angle in degrees. Rotation occurs counterclockwise.
cxX coordinate of rotation center. Optional, default 0.0.
cyY coordinate of rotation center. Optional, default 0.0.
Description

This method is typically only used by the Rotate method of class Icon.

See also

Icon::Rotate

method Rotate {angleDeg {cx 0.0} {cy 0.0}} {

    # Rotate the item around specified center.
    #
    # angleDeg - Rotation angle in degrees.
    #            Rotation occurs counterclockwise.
    # cx       - X coordinate of rotation center.
    # cy       - Y coordinate of rotation center.
    #
    # This method is typically only used by the `Rotate`
    # method of class `Icon`.
    #
    # See also: Icon::Rotate

    set angleRad [expr {$angleDeg * 3.14159265358979323846 / 180.0}]
    set coords [list]
    foreach { x y } $sCoordList {
        set rotPoint [::poFti::_Rotate $x $y $angleRad $cx $cy]
        lappend coords [lindex $rotPoint 0] [lindex $rotPoint 1]
    }
    set sCoordList $coords
}

Scale [::poFti::Item]Item, Top

Scale the item using specified center.

ITEMOBJ Scale sx sy ?cx? ?cy?
Parameters
sxX scale factor.
syY scale factor.
cxX coordinate of scale center. Optional, default 0.0.
cyY coordinate of scale center. Optional, default 0.0.
Description

This method is typically only used by the Scale method of class Icon.

See also

Icon::Scale

method Scale {sx sy {cx 0.0} {cy 0.0}} {

    # Scale the item using specified center.
    #
    # sx - X scale factor.
    # sy - Y scale factor.
    # cx - X coordinate of scale center.
    # cy - Y coordinate of scale center.
    #
    # This method is typically only used by the `Scale`
    # method of class `Icon`.
    #
    # See also: Icon::Scale

    set coords [list]
    foreach { x y } $sCoordList {
        set sclPoint [::poFti::_Scale $x $y $sx $sy $cx $cy]
        lappend coords [lindex $sclPoint 0] [lindex $sclPoint 1]
    }
    set sCoordList $coords
}

SetColor [::poFti::Item]Item, Top

Set the color of the item.

ITEMOBJ SetColor color
Parameters
colorColor number in the range [-255 .. 15] or special strings iconcolor, shadowcolor or outlinecolor.
Description

If $color is not a valid special color name or valid color number, an error is thrown.

See also

GetColor, SetColorRgb, SetOutlineColor, SetOutlineColorRgb

method SetColor {color} {

    # Set the color of the item.
    #
    # color - Color number in the range \[-255 .. 15\] or
    #         special strings `iconcolor`, `shadowcolor` or `outlinecolor`.
    #
    # If $color is not a valid special color name or valid color number,
    # an error is thrown.
    #
    # See also: GetColor SetColorRgb SetOutlineColor SetOutlineColorRgb

    if { ! [::poFti::IsSpecialColor $color] &&  ! [info exist ::poFti::sColorMap($color)] } {
        error "Invalid color \"$color\" specified."
    }
    set sColorNum $color
    set ::poFti::sCurColorNum $color
}

SetColorRgb [::poFti::Item]Item, Top

Set the color of the item.

ITEMOBJ SetColorRgb r g b
Parameters
rRed color.
gGreen color.
bBlue color.
Description

Color values are specified in the range [0 .. 255] and the best matching color number is choosen.

See also

GetColor, SetColor, SetOutlineColor, SetOutlineColorRgb, GetOutlineColor

method SetColorRgb {r g b} {

    # Set the color of the item.
    #
    # r - Red color.
    # g - Green color.
    # b - Blue color.
    #
    # Color values are specified in the range \[0 .. 255\]
    # and the best matching color number is choosen.
    #
    # See also: GetColor SetColor SetOutlineColor SetOutlineColorRgb GetOutlineColor

    set colorNum [::poFti::GetColorNumFromRgb $r $g $b]
    my SetColor $colorNum
}

SetColorRgbString [::poFti::Item]Item, Top

Set the color of the item.

ITEMOBJ SetColorRgbString rgbString
Parameters
rgbStringColor as hexadecimal string.
Description

Color values are specified in format #RRGGBB and the best matching color number is choosen.

See also

GetColor, SetColor, SetOutlineColor, SetOutlineColorRgb, GetOutlineColor

method SetColorRgbString {rgbString} {

    # Set the color of the item.
    #
    # rgbString - Color as hexadecimal string.
    #
    # Color values are specified in format `#RRGGBB`
    # and the best matching color number is choosen.
    #
    # See also: GetColor SetColor SetOutlineColor SetOutlineColorRgb GetOutlineColor

    set colorNum [::poFti::GetColorNumFromRgbString $rgbString]
    my SetColor $colorNum
}

SetName [::poFti::Item]Item, Top

Set the name of the item.

ITEMOBJ SetName name
Parameters
nameItem name.
See also

GetName, constructor

method SetName {name} {

    # Set the name of the item.
    #
    # name - Item name.
    #
    # See also: GetName constructor

    set sName $name
}

SetOutlineColor [::poFti::Item]Item, Top

Set the outline color of the item.

ITEMOBJ SetOutlineColor color
Parameters
colorColor number in the range [-255 .. 15] or special strings iconcolor, shadowcolor or outlinecolor.
Description

If $color is not a valid special color name or valid color number, an error is thrown.

See also

GetColor, SetColor, SetColorRgb, SetOutlineColorRgb, GetOutlineColor

method SetOutlineColor {color} {

    # Set the outline color of the item.
    #
    # color - Color number in the range \[-255 .. 15\] or
    #         special strings `iconcolor`, `shadowcolor` or `outlinecolor`.
    #
    # If $color is not a valid special color name or valid color number,
    # an error is thrown.
    #
    # See also: GetColor SetColor SetColorRgb SetOutlineColorRgb GetOutlineColor

    if { ! [::poFti::IsSpecialColor $color] &&  ! [info exist ::poFti::sColorMap($color)] } {
        error "Invalid color \"$color\" specified."
    }

    set sOutlineColorNum $color
}

SetOutlineColorRgb [::poFti::Item]Item, Top

Set the outline color of the item.

ITEMOBJ SetOutlineColorRgb r g b
Parameters
rRed color.
gGreen color.
bBlue color.
Description

Color values are specified in the range [0 .. 255] and the best matching color number is choosen.

See also

GetColor, SetColor, SetColorRgb, SetOutlineColor, GetOutlineColor

method SetOutlineColorRgb {r g b} {

    # Set the outline color of the item.
    #
    # r - Red color.
    # g - Green color.
    # b - Blue color.
    #
    # Color values are specified in the range \[0 .. 255\]
    # and the best matching color number is choosen.
    #
    # See also: GetColor SetColor SetColorRgb SetOutlineColor GetOutlineColor

    set colorNum [::poFti::GetColorNumFromRgb $r $g $b]
    my SetOutlineColor $colorNum
}

SetOutlineColorRgbString [::poFti::Item]Item, Top

Set the outline color of the item.

ITEMOBJ SetOutlineColorRgbString rgbString
Parameters
rgbStringColor as hexadecimal string.
Description

Color values are specified in format #RRGGBB and the best matching color number is choosen.

See also

GetColor, SetColor, SetOutlineColor, SetOutlineColorRgb, GetOutlineColor

method SetOutlineColorRgbString {rgbString} {

    # Set the outline color of the item.
    #
    # rgbString - Color as hexadecimal string.
    #
    # Color values are specified in format `#RRGGBB`
    # and the best matching color number is choosen.
    #
    # See also: GetColor SetColor SetOutlineColor SetOutlineColorRgb GetOutlineColor

    set colorNum [::poFti::GetColorNumFromRgbString $rgbString]
    my SetOutlineColor $colorNum
}

SetType [::poFti::Item]Item, Top

Set the type of the item.

ITEMOBJ SetType type
Parameters
typeItem type name.
Description

If $type is not a valid type name, an error is thrown.

See also

::poFti::GetTypeNames, GetType, constructor

method SetType {type} {

    # Set the type of the item.
    #
    # type - Item type name.
    #
    # If $type is not a valid type name,
    # an error is thrown.
    #
    # See also: ::poFti::GetTypeNames GetType constructor

    if { $type ni [poFti::GetTypeNames] } {
        error "Invalid type \"$type\" specified."
    }
    set sType $type
}

Write [::poFti::Item]Item, Top

Write the item to file.

ITEMOBJ Write fp
Parameters
fpFile pointer.
Description

This method is typically only used by the Write method of class Icon.

See also

Icon::Write

method Write {fp} {

    # Write the item to file.
    #
    # fp - File pointer.
    #
    # This method is typically only used by the `Write`
    # method of class `Icon`.
    #
    # See also: Icon::Write

    puts $fp "#\t$sName"
    if { $sColorNum != $::poFti::sLastColorNumWritten } {
        puts $fp "\t\tcolor($sColorNum);"
        set ::poFti::sLastColorNumWritten $sColorNum
    }
    if { $sType eq "line" } {
        puts $fp "\t\tbgnline();"
    } elseif { $sType eq "closedline" } {
        puts $fp "\t\tbgnclosedline();"
    } elseif { $sType eq "polygon" } {
        puts $fp "\t\tbgnpolygon();"
    } elseif { $sType eq "outlinepolygon" } {
        puts $fp "\t\tbgnoutlinepolygon();"
    } elseif { $sType eq "point" } {
        puts $fp "\t\tbgpoint();"
    }
    foreach { x y } $sCoordList {
        puts $fp [format "\t\t\tvertex(%.2f, %.2f);" $x $y]
    }
    if { $sType eq "line" } {
        puts $fp "\t\tendline();"
    } elseif { $sType eq "closedline" } {
        puts $fp "\t\tendclosedline();"
    } elseif { $sType eq "polygon" } {
        puts $fp "\t\tendpolygon();"
    } elseif { $sType eq "outlinepolygon" } {
        puts $fp "\t\tendoutlinepolygon($sOutlineColorNum);"
    } elseif { $sType eq "point" } {
        puts $fp "\t\tendpoint();"
    }
    puts $fp ""
}