Changeset 1075 for trunk/gui/scripts/spectrum.tcl
- Timestamp:
- Jul 18, 2008, 11:57:18 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/spectrum.tcl
r115 r1075 36 36 private variable _gvals "" ;# list of green components along axis 37 37 private variable _bvals "" ;# list of blue components along axis 38 private variable _spectrum 0 ;# use continuous visible spectrum 39 private variable _specv0 0 ;# minimum value 40 private variable _specw0 0 ;# wavelength for minimum 38 41 } 39 42 … … 61 64 itcl::body Rappture::Spectrum::insert {args} { 62 65 set changed 0 66 67 # special case. Two values in nm, then use 68 # spectrum instead of gradient. 69 if {[llength $args] == 4} { 70 set cnt 0 71 foreach {value color} $args { 72 if {[string match "*nm" $color]} { 73 incr cnt 74 } 75 } 76 if {$cnt == 2} { 77 set val0 [lindex $args 0] 78 set color0 [string trimright [lindex $args 1] "nm"] 79 set val1 [lindex $args 2] 80 set color1 [string trimright [lindex $args 3] "nm"] 81 82 if {"" != $units} { 83 set val0 [Rappture::Units::convert $val0 \ 84 -context $units -to $units -units off] 85 set val1 [Rappture::Units::convert $val1 \ 86 -context $units -to $units -units off] 87 } 88 89 set _spectrum [expr (double($color1) - double($color0)) \ 90 / (double($val1) - double($val0))] 91 set _specv0 $val0 92 set _specw0 $color0 93 return 94 } 95 } 96 63 97 foreach {value color} $args { 64 98 if {"" != $units} { … … 66 100 -context $units -to $units -units off] 67 101 } 68 foreach {r g b} [winfo rgb . $color] { break } 69 102 foreach {r g b} [Rappture::color::RGB $color] { break } 70 103 set i 0 71 104 foreach v $_axis { … … 172 205 switch -- $what { 173 206 -color { 207 if {$_spectrum != 0} { 208 # continuous spectrum. just compute wavelength 209 set waveln [expr ($value - $_specv0) * $_spectrum + $_specw0] 210 return [Rappture::color::wave2RGB $waveln] 211 } 174 212 set i 0 175 213 set ilast ""
Note: See TracChangeset
for help on using the changeset viewer.