This file is indexed.

/usr/share/doc/libplplot12/examples/tcl/x02.tcl is in plplot-tcl-dev 5.10.0+dfsg2-0.1ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#----------------------------------------------------------------------------
# $Id: x02.tcl 12288 2013-01-30 04:40:35Z airwin $
#----------------------------------------------------------------------------

proc x02 {{w loopback}} {

    x02_demo1 $w
    x02_demo2 $w

# Restore defaults
    $w cmd plssub 1 1
    $w cmd plfont 1
    # $w cmd plcol0 1
}

# Demonstrates multiple windows and default color map 0 palette.
# Divides screen into 16 regions.

proc x02_demo1 {w} {

    $w cmd plbop

    $w cmd plssub 4 4

    x02_draw_windows $w 16

    $w cmd pleop
}

# Demonstrates multiple windows, user-modified color map 0 palette, and
# HLS -> RGB translation.  Divides screen into 100 regions.

proc x02_demo2 {w} {

    $w cmd plbop

    $w cmd plssub 10 10

# Set up cmap0 
# Use 100 custom colors in addition to base 16
    set npts 100
    set offset 16
    set ntot [expr $npts + $offset]
    matrix r f $ntot
    matrix g f $ntot
    matrix b f $ntot

# Min & max lightness values
    set lmin 0.15
    set lmax 0.85

# The faster way to allocate also crashes, so stick with the slow way until we
# can resolve this.  Set the following to 1 to see the bug.. :)
    set see_the_bug 0
    if !$see_the_bug {
        $w cmd plscmap0n $ntot
    }

    for {set i 0} {$i < $npts} {incr i} {
        set i1 [expr $i + $offset]

    # Bounds on HLS, from plhlsrgb() commentary --
    #	hue		[0., 360.]	degrees
    #	lightness	[0., 1.]	magnitude
    #	saturation	[0., 1.]	magnitude

    # Vary hue uniformly from left to right
        set h [expr (360. / 10. ) * ( $i % 10 )]
    # Vary lightness uniformly from top to bottom, between min & max
        set l [expr $lmin + ($lmax - $lmin) * ($i / 10) / 9.]
    # Use max saturation
        set s 1.0

        $w cmd plhlsrgb $h $l $s r1 g1 b1
	# puts [format "%3d %15.9f %15.9f %15.9f %15.9f %15.9f %15.9f" $i1 $h $l $s $r1 $g1 $b1]
        if $see_the_bug {
            r $i1 = [expr int($r1 * 255.001)]
            g $i1 = [expr int($g1 * 255.001)]
            b $i1 = [expr int($b1 * 255.001)]
        } else {
            set r2 [expr int($r1 * 255.001)]
            set g2 [expr int($g1 * 255.001)]
            set b2 [expr int($b1 * 255.001)]
  	    # puts [format "%3d %3d %3d %3d" $i1 $r2 $g2 $b2]
            $w cmd plscol0 $i1 $r2 $g2 $b2
        }
    }

    if $see_the_bug {
       # Load default cmap0 colors into our custom set
       for {set i 0} {$i < $offset} {incr i} {
	  plgcol0 $i r1 g1 b1
	  r $i = [expr int($r1)]
	  g $i = [expr int($g1)]
	  b $i = [expr int($b1)]
       }
       # temporary
       for {set i 0} {$i < $ntot} {incr i} {
	  set r1 [expr [r $i]]
	  set g1 [expr [g $i]]
	  set b1 [expr [b $i]]
  	  puts [format "%3d %3d %3d %3d" $i $r1 $g1 $b1]
       }
       # The following call currently segfaults.
       $w cmd plscmap0 r g b $ntot
    }

    x02_draw_windows $w 100 $offset

    $w cmd pleop
}


# Draws a set of numbered boxes with colors according to cmap0 entry.

proc x02_draw_windows { w nw {cmap0_offset 0} } {

    $w cmd plschr 0.0 3.5
    $w cmd plfont 4

    for {set i 0} {$i < $nw} {incr i} {
	$w cmd plcol0 [expr $i + $cmap0_offset]
	$w cmd pladv 0
	set vmin 0.1
	set vmax 0.9
	for {set j 0} {$j <= 2} {incr j} {
	    $w cmd plwidth [expr $j+1]
	    $w cmd plvpor $vmin $vmax $vmin $vmax
	    $w cmd plwind 0.0 1.0 0.0 1.0
	    $w cmd plbox "bc" 0.0 0 "bc" 0.0 0
	    set vmin [expr $vmin+0.1]
	    set vmax [expr $vmax-0.1]
	}
	$w cmd plwidth 1
	$w cmd plptex 0.5 0.5 1.0 0.0 0.5 $i
    }

    $w cmd pleop
}