Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Changed demos GUI to use grid over pack, and changed the API to the GUI extensibility. Updated all demos to the new extensibility API. Changed several demos to use plot widgets to show the curves they are using. |
|---|---|
| Timelines: | family | ancestors | descendants | both | ak-experimental |
| Files: | files | file ages | folders |
| SHA1: |
f5b2cc8125081c5143eca801201a0e19 |
| User & Date: | andreask 2010-07-10 23:21:33.000 |
Context
|
2010-07-11
| ||
| 01:31 |
Reworked the plot widget. Added the ability to have a free-wheeling y-axis, i.e. auto-adapting to the contents of the shown series. Trouble with reconfiguring the axis after the creation of the plot made me change things, i.e. now the plot is completely recreated on every change of the series. This also fixes the problems I had with keeping old data in the display. Last change, the update of the display after changes is now properly defered until the GUI is idle.check-in: d51f699bad user: andreask tags: ak-experimental | |
|
2010-07-10
| ||
| 23:21 |
Changed demos GUI to use grid over pack, and changed the API to the GUI extensibility. Updated all demos to the new extensibility API. Changed several demos to use plot widgets to show the curves they are using.check-in: f5b2cc8125 user: andreask tags: ak-experimental | |
| 23:19 | Added another table generator, which wraps on over- and underflow, instead of clamping check-in: a5062dc2b6 user: andreask tags: ak-experimental | |
Changes
Changes to demos.tcl.
| ︙ | ︙ | |||
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 |
uplevel #0 [dict get $demo($name) setup]
return
}
proc demo_close {} {
global demo dcurrent
if {$dcurrent eq {}} return
uplevel #0 [dict get $demo($dcurrent) shutdown]
set dcurrent {}
return
}
proc def {name dict} {
upvar 1 thedemo thedemo
lappend thedemo setup {} shutdown {} {*}$dict name $name
return
}
# # ## ### ##### ######## #############
proc gui {} {
widget::toolbar .t
.t add button reset -text Reset -command reset
set sep 1
foreach demo [demo_list] {
.t add button $demo \
-text [demo_label $demo] \
-command [list demo_setup $demo] \
-separator $sep
set sep 0
}
.t add button exit -text Exit -command ::exit -separator 1
widget::scrolledwindow .sc -borderwidth 1 -relief sunken
widget::scrolledwindow .sl -borderwidth 1 -relief sunken
canvas .c -width 800 -height 600 -scrollregion {-4000 -4000 4000 4000}
listbox .l -width 40 -selectmode extended -listvariable images
.c create image {0 0} -anchor nw -tags photo
.c itemconfigure photo -image [image create photo]
.sl setwidget .l
.sc setwidget .c
| > > > > > > > > > > > > > > > > > > > > > > > | | | > | 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 140 141 142 143 144 145 146 147 148 149 150 |
uplevel #0 [dict get $demo($name) setup]
return
}
proc demo_close {} {
global demo dcurrent
if {$dcurrent eq {}} return
destroy \
{*}[winfo children .left] \
{*}[winfo children .right] \
{*}[winfo children .top] \
{*}[winfo children .bottom]
reframe
uplevel #0 [dict get $demo($dcurrent) shutdown]
set dcurrent {}
return
}
proc def {name dict} {
upvar 1 thedemo thedemo
lappend thedemo setup {} shutdown {} {*}$dict name $name
return
}
# # ## ### ##### ######## #############
proc reframe {} {
grid forget .left .right .top .bottom
grid .left -row 2 -column 1 -sticky swen
grid .right -row 2 -column 3 -sticky swen
grid .top -row 1 -column 1 -columnspan 3 -sticky swen
grid .bottom -row 3 -column 1 -columnspan 3 -sticky swen
return
}
proc gui {} {
widget::toolbar .t
.t add button reset -text Reset -command reset
set sep 1
foreach demo [demo_list] {
.t add button $demo \
-text [demo_label $demo] \
-command [list demo_setup $demo] \
-separator $sep
set sep 0
}
.t add button exit -text Exit -command ::exit -separator 1
widget::scrolledwindow .sc -borderwidth 1 -relief sunken
widget::scrolledwindow .sl -borderwidth 1 -relief sunken
canvas .c -width 800 -height 600 -scrollregion {-4000 -4000 4000 4000}
listbox .l -width 40 -selectmode extended -listvariable images
ttk::frame .left
ttk::frame .top
ttk::frame .right
ttk::frame .bottom
.c create image {0 0} -anchor nw -tags photo
.c itemconfigure photo -image [image create photo]
.sl setwidget .l
.sc setwidget .c
grid .t -row 0 -column 0 -columnspan 4 -sticky swen
grid .sl -row 1 -column 0 -rowspan 3 -sticky swen
grid .sc -row 2 -column 2 -sticky swen
reframe
bind .l <<ListboxSelect>> show_selection
# Panning via mouse
bind .c <ButtonPress-2> {%W scan mark %x %y}
bind .c <B2-Motion> {%W scan dragto %x %y}
|
| ︙ | ︙ | |||
174 175 176 177 178 179 180 |
}
proc base {{i 0}} {
global base
return [lindex $base $i]
}
| < < < < < | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
}
proc base {{i 0}} {
global base
return [lindex $base $i]
}
# # ## ### ##### ######## #############
proc main {} {
images_init
gui
after 100 {show 0}
return
}
main
vwait forever
# vim: set sts=4 sw=4 tw=80 et ft=tcl:
|
Changes to demos/blend_hsv.tcl.
1 2 3 |
def op_alpha_blend_hsv {
label {Blend HSV}
setup {
| | | | | | | < | | < | | | | | > < | | 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 |
def op_alpha_blend_hsv {
label {Blend HSV}
setup {
set ::ALPHA 255
# We manage a cache of the blended images to make the
# scrolling of the scale smoother over time. An improvement
# would be to use timer events to precompute the various
# blends.
array set ::CACHE {}
set ::CACHE(255) [base 0]
set ::CACHE(0) [base 1]
set ::FORE [crimp convert 2hsv [base 0]]
set ::BACK [crimp convert 2hsv [base 1]]
scale .left.s -variable ::ALPHA \
-from 0 -to 255 \
-orient vertical \
-command [list ::apply {{alpha} {
if {[info exists ::CACHE($alpha)]} {
show_image $::CACHE($alpha)
return
}
set blend [crimp convert 2rgb [crimp blend $::FORE $::BACK $alpha]]
show_image $blend
set ::CACHE($alpha) $blend
return
}}]
pack .left.s -side left -fill both -expand 1
}
shutdown {
unset ::ALPHA ::CACHE ::BACK ::FORE
}
}
|
Changes to demos/blend_rgb.tcl.
1 2 3 |
def op_alpha_blend_rgb {
label {Blend RGB}
setup {
| | | | | < | | < | | | | > < | | 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 |
def op_alpha_blend_rgb {
label {Blend RGB}
setup {
set ::ALPHA 255
set ::BLACK [crimp blank rgba 800 600 0 0 0 255]
# We manage a cache of the blended images to make the
# scrolling of the scale smoother over time. An improvement
# would be to use timer events to precompute the various
# blends.
array set ::CACHE {}
set ::CACHE(255) [base 0]
set ::CACHE(0) [base 1]
scale .left.s -variable ::ALPHA \
-from 0 -to 255 \
-orient vertical \
-command [list ::apply {{alpha} {
if {[info exists ::CACHE($alpha)]} {
show_image $::CACHE($alpha)
return
}
set blend [crimp blend [base 0] [base 1] $alpha]
show_image [crimp setalpha $blend $::BLACK]
set ::CACHE($alpha) $blend
return
}}]
pack .left.s -side left -fill both -expand 1
}
shutdown {
unset ::ALPHA ::BLACK ::CACHE
}
}
|
Changes to demos/degamma.tcl.
1 2 3 4 |
def op_gamma_invers {
label Degamma
setup {
set ::DEGAMMA 1
| > | > | < < | > | | > > < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
def op_gamma_invers {
label Degamma
setup {
set ::DEGAMMA 1
set ::TABLE {}
plot .left.p -variable ::TABLE
scale .left.g -variable ::DEGAMMA \
-from 5 -to 1 -resolution 0.01 \
-orient vertical \
-command [list ::apply {{gamma} {
set ::TABLE [crimp table degamma $gamma]
show_image [crimp degamma [base] $gamma]
}}]
grid .left.p -row 0 -column 0 -sticky swen
grid .left.g -row 0 -column 1 -sticky swen
}
shutdown {
unset ::DEGAMMA ::TABLE
}
}
|
Changes to demos/gamma.tcl.
1 2 3 4 |
def op_gamma {
label Gamma
setup {
set ::GAMMA 1
| > | > | < < | > | | > > < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
def op_gamma {
label Gamma
setup {
set ::GAMMA 1
set ::TABLE {}
plot .left.p -variable ::TABLE
scale .left.g -variable ::GAMMA \
-from 5 -to 1 -resolution 0.01 \
-orient vertical \
-command [list ::apply {{gamma} {
set ::TABLE [crimp table gamma $gamma]
show_image [crimp gamma [base] $gamma]
}}]
grid .left.p -row 0 -column 0 -sticky swen
grid .left.g -row 0 -column 1 -sticky swen
}
shutdown {
unset ::GAMMA ::TABLE
}
}
|
Changes to demos/matrix.tcl.
1 2 3 |
def effect_matrix {
label RotMatrix
setup {
| > | > | | < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
def effect_matrix {
label RotMatrix
setup {
scale .left.s \
-from -180 -to 180 -resolution 0.01 \
-orient vertical \
-command [list ::apply {{angle} {
set s [expr {sin($angle * 0.017453292519943295769236907684886)}]
set c [expr {cos($angle * 0.017453292519943295769236907684886)}]
set matrix [list \
[list $c $s 0] \
[list [expr {-$s}] $c 0] \
[list $s $s 1]]
#puts matrix...
show_image [crimp matrix [base] $matrix]
}}]
pack .left.s -side left -fill both -expand 1
}
}
|
Changes to demos/rehsv.tcl.
1 2 3 |
def effect_rehsv {
label {Change HSV}
setup {
| > | > > > > | > > > > | > > > > > > > > > | > > > > | > | > > > | | | | | < | | | | | | > | | | > > > > | < | 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 |
def effect_rehsv {
label {Change HSV}
setup {
set ::HSVBASE [crimp convert 2hsv [base]]
set ::GHG 1
set ::GHB 0
set ::TH [crimp table gainw $::GHG $::GHB]
set ::MH [crimp map gainw $::GHG $::GHB]
set ::GS 1 ; set ::TS [crimp table gain $::GS] ; set ::MS [crimp map gain $::GS]
set ::GV 1 ; set ::TV [crimp table gain $::GV] ; set ::MV [crimp map gain $::GV]
proc HG {gain} {
set ::TH [crimp table gainw $gain $::GHB]
set ::MH [crimp map gainw $gain $::GHB]
UPDATE
}
proc HB {bias} {
set ::TH [crimp table gainw $::GHG $bias]
set ::MH [crimp map gainw $::GHG $bias]
UPDATE
}
proc S {gain} {
set ::TS [crimp table gain $gain]
set ::MS [crimp map gain $gain]
UPDATE
}
proc V {gain} {
set ::TV [crimp table gain $gain]
set ::MV [crimp map gain $gain]
UPDATE
}
proc ::UPDATE {} {
global MH MS MV HSVBASE
show_image [crimp convert 2rgb [crimp remap $HSVBASE $MH $MS $MV]]
return
}
scale .left.hg -variable ::GHG -from 0 -to 20 -resolution 0.01 -orient vertical -command HG
scale .left.hb -variable ::GHB -from 0 -to 255 -resolution 1 -orient vertical -command HB
scale .left.s -variable ::GS -from 0 -to 20 -resolution 0.01 -orient vertical -command S
scale .left.v -variable ::GV -from 0 -to 20 -resolution 0.01 -orient vertical -command V
plot .left.ph -variable ::TH
plot .left.ps -variable ::TS
plot .left.pv -variable ::TV
grid .left.hg -row 0 -column 0 -sticky sen
grid .left.ph -row 0 -column 1 -sticky swen
grid .left.hb -row 0 -column 2 -sticky sen
grid .left.pv -row 1 -column 1 -sticky swen
grid .left.v -row 1 -column 2 -sticky sen
grid .left.ps -row 2 -column 1 -sticky swen
grid .left.s -row 2 -column 2 -sticky sen
}
shutdown {
rename HG {}
rename HB {}
rename S {}
rename V {}
unset ::GHG ::GHB ::GS ::GV ::TH ::TS ::TV ::MH ::MS ::MV ::HSVBASE
}
}
|
Changes to demos/solarize.tcl.
1 2 3 |
def op_solarize {
label Solarize
setup {
| > | | | > | < | > | | > > < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
def op_solarize {
label Solarize
setup {
set ::THRESHOLD 256
set ::TABLE {}
plot .left.p -variable ::TABLE
scale .left.s -variable ::THRESHOLD \
-from 0 -to 256 \
-orient horizontal \
-command [list ::apply {{threshold} {
set ::TABLE [crimp table solarize $threshold]
show_image [crimp solarize [base] $threshold]
}}]
grid .left.s -row 0 -column 0 -sticky swen
grid .left.p -row 1 -column 0 -sticky swen
}
shutdown {
unset ::THRESHOLD ::TABLE
}
}
|
Changes to demos/wavy.tcl.
1 2 3 4 |
def effect_wavy {
label Wavy
setup {
proc ::W {args} {
| | | | | | < < | | | | | | | < < | < | 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 |
def effect_wavy {
label Wavy
setup {
proc ::W {args} {
global WA WB WC
show_image [crimp wavy [base] $WA $WB $WC]
return
}
set ::WA 1
set ::WB 1
set ::WC 1
scale .left.wa -variable ::WA -from -20 -to 20 -resolution 0.01 -orient vertical -command ::W
scale .left.wb -variable ::WB -from -20 -to 20 -resolution 0.01 -orient vertical -command ::W
scale .left.wc -variable ::WC -from -20 -to 20 -resolution 0.01 -orient vertical -command ::W
pack .left.wa -side left -expand 1 -fill both
pack .left.wb -side left -expand 1 -fill both
pack .left.wc -side left -expand 1 -fill both
}
shutdown {
unset ::WA ::WB ::WC
}
}
|