CRIMP
Check-in [93e9361948]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Demos. Updated to take advantage of their code running in a namespace.
Timelines: family | ancestors | descendants | both | ak-experimental
Files: files | file ages | folders
SHA1: 93e9361948406ebf4c89fc7395297c9277acb69d
User & Date: andreask 2010-07-15 06:41:00.000
Context
2010-07-15
19:03
Demos.

The demos are now handled like they are in a matrix, with the choice of images and actions as the two axes.

Choose an action and it applies to the current image. Choose an image and the current action is applied.

So, choose an image and walk the toolbar to see the various actions. Or, choose an action, maybe parameterize it, and then walk the images. check-in: 8ee78df8f1 user: andreask tags: ak-experimental

06:41
Demos. Updated to take advantage of their code running in a namespace. check-in: 93e9361948 user: andreask tags: ak-experimental
05:39
Demos. Moved execution of demo code into a namespace. Updated demos negatively affected by this back to working order. check-in: 8f6d5aad23 user: andreask tags: ak-experimental
Changes
Unified Diff Ignore Whitespace Patch
Changes to demos/blend_hsv.tcl.
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
def op_alpha_blend_hsv {
    label {Blend HSV}
    active { expr {[bases] == 2} }
    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
    }
}




<




>
|
|
|
|
|
>

|


|
>
>
>
>
|
|



|
>
|
<

|


<
<
<


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
def op_alpha_blend_hsv {
    label {Blend HSV}
    active { expr {[bases] == 2} }
    setup {

	# 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.
	variable  cache
	array set cache {}
	set cache(255) [base 0]
	set cache(0)   [base 1]
	variable fore  [crimp convert 2hsv [base 0]]
	variable back  [crimp convert 2hsv [base 1]]
	variable alpha 255

	scale .left.s -variable DEMO::alpha \
	    -from 0 -to 255 \
	    -orient vertical \
	    -command [list ::apply {{thealpha} {
		variable cache
		variable fore
		variable back

		if {[info exists cache($thealpha)]} {
		    show_image  $cache($thealpha)
		    return
		}

		set theblend [crimp convert 2rgb [crimp blend $fore $back $thealpha]]
		set cache($thealpha) $theblend
		show_image $theblend

		return
	    } ::DEMO}]

	pack .left.s -side left -fill both -expand 1



    }
}
Changes to demos/blend_rgb.tcl.
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_rgb {
    label {Blend RGB}
    active { expr {[bases] == 2} }
    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
    }
}




<
<




>
|
|
|
>
>

|


|
>
>
>
|
|



|
>
|
<

|


<
<
<


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
def op_alpha_blend_rgb {
    label {Blend RGB}
    active { expr {[bases] == 2} }
    setup {


	# 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.
	variable  cache
	array set cache {}
	set cache(255) [base 0]
	set cache(0)   [base 1]
	variable black [crimp blank rgba 800 600 0 0 0 255]
	variable alpha 255

	scale .left.s -variable DEMO::alpha \
	    -from 0 -to 255 \
	    -orient vertical \
	    -command [list ::apply {{thealpha} {
		variable cache
		variable black

		if {[info exists cache($thealpha)]} {
		    show_image  $cache($thealpha)
		    return
		}

		set theblend [crimp blend [base 0] [base 1] $thealpha]
		set cache($thealpha) $theblend
		show_image $theblend

		return
	    } ::DEMO}]

	pack .left.s -side left -fill both -expand 1



    }
}
Changes to demos/degamma.tcl.
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
    }
}



|
|

|
|


|
|
|
|


|
<
<
<


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17



18
19
def op_gamma_invers {
    label Degamma
    setup {
	variable gamma 1
	variable table {}

	plot  .left.p -variable ::DEMO::table -title {Invers Gamma}
	scale .left.s -variable ::DEMO::gamma \
	    -from 5 -to 1 -resolution 0.01 \
	    -orient vertical \
	    -command [list ::apply {{thegamma} {
		variable table [crimp table degamma  $thegamma]
		show_image     [crimp degamma [base] $thegamma]
	    } ::DEMO}]

	grid .left.p -row 0 -column 0 -sticky swen
	grid .left.s -row 0 -column 1 -sticky swen



    }
}
Changes to demos/gamma.tcl.
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
    }
}



|
|

|
|


|
|
|
|


|
<
<
<


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17



18
19
def op_gamma {
    label Gamma
    setup {
	variable gamma 1
	variable table {}

	plot  .left.p -variable ::DEMO::table -title Gamma
	scale .left.s -variable ::DEMO::gamma \
	    -from 5 -to 1 -resolution 0.01 \
	    -orient vertical \
	    -command [list ::apply {{thegamma} {
		variable table [crimp table gamma  $thegamma]
		show_image     [crimp gamma [base] $thegamma]
	    } ::DEMO}]

	grid .left.p -row 0 -column 0 -sticky swen
	grid .left.s -row 0 -column 1 -sticky swen



    }
}
Changes to demos/histogram.tcl.
1
2
3
4
5
6
7
8
9
10


11
12
13


14
15
16
17
18
19
20
def effect_histogram {
    label Histogram
    setup {
	set ::TR {0 1}
	set ::TG {0 1}
	set ::TB {0 1}
	set ::TS {0 1}
	set ::TV {0 1}
	set ::TL {0 1}



	proc ::HISTO {image} {
	    global HR HG HB HL HH HS HV
	    global TR TG TB TL    TS TV



	    array set TMP [crimp histogram $image]
	    array set TMP [crimp histogram [crimp convert 2grey8 $image]]
	    array set TMP [crimp histogram [crimp convert 2hsv   $image]]

	    set HR [dict values $TMP(red)]   ; set TR [CUMULATE $HR]
	    set HG [dict values $TMP(green)] ; set TG [CUMULATE $HG]



|
|
|
|
|
|

>
>
|
<
<
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13


14
15
16
17
18
19
20
21
22
def effect_histogram {
    label Histogram
    setup {
	variable TR {0 1}
	variable TG {0 1}
	variable TB {0 1}
	variable TS {0 1}
	variable TV {0 1}
	variable TL {0 1}

	variable mask [lindex [crimp split [base]] end]

	proc HISTO {image} {


	    variable HR ; variable HG ; variable HB ; variable HL ; variable HH ; variable HS ; variable HV
	    variable TR ; variable TG ; variable TB ; variable TL ;               variable TS ; variable TV 

	    array set TMP [crimp histogram $image]
	    array set TMP [crimp histogram [crimp convert 2grey8 $image]]
	    array set TMP [crimp histogram [crimp convert 2hsv   $image]]

	    set HR [dict values $TMP(red)]   ; set TR [CUMULATE $HR]
	    set HG [dict values $TMP(green)] ; set TG [CUMULATE $HG]
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
140
141
142
143
144
145
146
	    lset HL 0 0 ; lset HL 255 0

	    lset HS 0 0 ; lset HS 255 0
	    lset HV 0 0 ; lset HV 255 0
	    return
	}

	proc ::EQNONE {} {
	    HISTO [base]
	    show_image [base]

	}

	proc ::EQHSV {} {
	    HISTO [base]
	    # H is not stretched. Does not make sense for HUE.

	    global HH HS HV TS TV


	    set fs [FIT $TS 255]
	    set fv [FIT $TV 255]

	    set h [crimp map identity]
	    #set s [crimp map identity]
	    #set v [crimp map identity]
	    set s [crimp read tcl [list $fs]]
	    set v [crimp read tcl [list $fv]]


	    set new [crimp convert 2rgb \
			 [crimp remap \
			      [crimp convert 2hsv [base]] \
			      $h $s $v]]


	    show_image $new
	    HISTO $new
	    return
	}

	proc ::EQRGB {} {
	    HISTO [base]
	    global HR HG HB TR TG TB


	    set fr [FIT $TR 255]
	    set fg [FIT $TG 255]
	    set fb [FIT $TB 255]

	    set r [crimp read tcl [list $fr]]
	    set g [crimp read tcl [list $fg]]
	    set b [crimp read tcl [list $fb]]

	    set new [crimp remap [base] $r $g $b]

	    show_image $new
	    HISTO $new
	    return
	}

	# series(int) --> series (int)
	proc ::CUMULATE {series} {
	    set res {}
	    set sum 0
	    foreach x $series {
		lappend res $sum
		incr sum $x
	    }
	    return $res
	}

	# series(int/float) --> series(int), all(x): x <= max
	proc ::FIT {series max} {
	    # Assumes that the input is a monotonically increasing
	    # series. The maximum value of the series is at the end.
	    set top [lindex $series end]
	    set f   [expr {double($max) / double($top)}]
	    set res {}

	    foreach x $series {
		lappend res [expr {round(double($x)*$f)}]
	    }
	    return $res
	}

	HISTO [base]

	# For the sake of the display we cut out the pure white and
	# black, as they are likely outliers with an extreme number of
	# pixels using them.
	
	plot  .left.hr -variable ::HR -locked 0 -title Red
	plot  .left.hg -variable ::HG -locked 0 -title Green
	plot  .left.hb -variable ::HB -locked 0 -title Blue

	plot  .top.hl -variable ::HL -locked 0 -title Luma
	plot  .top.hh -variable ::HH -locked 0 -title Hue
	plot  .top.hs -variable ::HS -locked 0 -title Saturation
	plot  .top.hv -variable ::HV -locked 0 -title Value

	ttk::button .right.eqhsv  -text {Equalize HSV}  -command ::EQHSV
	ttk::button .right.eqrgb  -text {Equalize RGB}  -command ::EQRGB
	ttk::button .right.eqnone -text {Equalize None} -command ::EQNONE

	plot  .right.tr -variable ::TR -locked 0 -title {CDF Red}
	plot  .right.tg -variable ::TG -locked 0 -title {CDF Green}
	plot  .right.tb -variable ::TB -locked 0 -title {CDF Blue}
	plot  .top.tl   -variable ::TL -locked 0 -title {CDF Luma}
	plot  .top.ts   -variable ::TS -locked 0 -title {CDF Saturation}
	plot  .top.tv   -variable ::TV -locked 0 -title {CDF Value}


	grid .left.hr -row 0 -column 0 -sticky swen
	grid .left.hg -row 1 -column 0 -sticky swen
	grid .left.hb -row 2 -column 0 -sticky swen

	grid .top.hl -row 0 -column 0 -sticky swen







|


>


|


>
|
>










>
|
|
|
|
>






|

|
>

















|










|


















|
|
|

|
|
|
|

|
|
|

|
|
|
|
|
|







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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
	    lset HL 0 0 ; lset HL 255 0

	    lset HS 0 0 ; lset HS 255 0
	    lset HV 0 0 ; lset HV 255 0
	    return
	}

	proc EQNONE {} {
	    HISTO [base]
	    show_image [base]
	    return
	}

	proc EQHSV {} {
	    HISTO [base]
	    # H is not stretched. Does not make sense for HUE.
	    variable HH ; variable HS ; variable HV
	                  variable TS ; variable TV
	    variable mask

	    set fs [FIT $TS 255]
	    set fv [FIT $TV 255]

	    set h [crimp map identity]
	    #set s [crimp map identity]
	    #set v [crimp map identity]
	    set s [crimp read tcl [list $fs]]
	    set v [crimp read tcl [list $fv]]

	    set new [crimp setalpha \
			 [crimp convert 2rgb \
			      [crimp remap \
				   [crimp convert 2hsv [base]] \
				   $h $s $v]] \
			 $mask]

	    show_image $new
	    HISTO $new
	    return
	}

	proc EQRGB {} {
	    HISTO [base]
	    variable HR ; variable HG ; variable HB
	    variable TR ; variable TG ; variable TB

	    set fr [FIT $TR 255]
	    set fg [FIT $TG 255]
	    set fb [FIT $TB 255]

	    set r [crimp read tcl [list $fr]]
	    set g [crimp read tcl [list $fg]]
	    set b [crimp read tcl [list $fb]]

	    set new [crimp remap [base] $r $g $b]

	    show_image $new
	    HISTO $new
	    return
	}

	# series(int) --> series (int)
	proc CUMULATE {series} {
	    set res {}
	    set sum 0
	    foreach x $series {
		lappend res $sum
		incr sum $x
	    }
	    return $res
	}

	# series(int/float) --> series(int), all(x): x <= max
	proc FIT {series max} {
	    # Assumes that the input is a monotonically increasing
	    # series. The maximum value of the series is at the end.
	    set top [lindex $series end]
	    set f   [expr {double($max) / double($top)}]
	    set res {}

	    foreach x $series {
		lappend res [expr {round(double($x)*$f)}]
	    }
	    return $res
	}

	HISTO [base]

	# For the sake of the display we cut out the pure white and
	# black, as they are likely outliers with an extreme number of
	# pixels using them.
	
	plot  .left.hr -variable ::DEMO::HR -locked 0 -title Red
	plot  .left.hg -variable ::DEMO::HG -locked 0 -title Green
	plot  .left.hb -variable ::DEMO::HB -locked 0 -title Blue

	plot  .top.hl -variable ::DEMO::HL -locked 0 -title Luma
	plot  .top.hh -variable ::DEMO::HH -locked 0 -title Hue
	plot  .top.hs -variable ::DEMO::HS -locked 0 -title Saturation
	plot  .top.hv -variable ::DEMO::HV -locked 0 -title Value

	ttk::button .right.eqhsv  -text {Equalize HSV}  -command ::DEMO::EQHSV
	ttk::button .right.eqrgb  -text {Equalize RGB}  -command ::DEMO::EQRGB
	ttk::button .right.eqnone -text {Equalize None} -command ::DEMO::EQNONE

	plot  .right.tr -variable ::DEMO::TR -locked 0 -title {CDF Red}
	plot  .right.tg -variable ::DEMO::TG -locked 0 -title {CDF Green}
	plot  .right.tb -variable ::DEMO::TB -locked 0 -title {CDF Blue}
	plot  .top.tl   -variable ::DEMO::TL -locked 0 -title {CDF Luma}
	plot  .top.ts   -variable ::DEMO::TS -locked 0 -title {CDF Saturation}
	plot  .top.tv   -variable ::DEMO::TV -locked 0 -title {CDF Value}


	grid .left.hr -row 0 -column 0 -sticky swen
	grid .left.hg -row 1 -column 0 -sticky swen
	grid .left.hb -row 2 -column 0 -sticky swen

	grid .top.hl -row 0 -column 0 -sticky swen
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
	grid .right.tr -row 3 -column 0 -sticky swen
	grid .right.tg -row 4 -column 0 -sticky swen
	grid .right.tb -row 5 -column 0 -sticky swen

	grid .top.tl -row 1 -column 0 -sticky swen
	grid .top.ts -row 1 -column 2 -sticky swen
	grid .top.tv -row 1 -column 3 -sticky swen

    }
    shutdown {
	rename ::HISTO    {} ; rename ::EQRGB  {}
	rename ::FIT      {} ; rename ::EQHSV  {}
	rename ::CUMULATE {} ; rename ::EQNONE {}
	unset ::HR ::HG ::HB ::HL ::HH ::HS ::HV ::TR ::TG ::TB ::TS ::TV ::TL
    }
}







|
|
<
<
<
<
<
<
<
163
164
165
166
167
168
169
170
171







	grid .right.tr -row 3 -column 0 -sticky swen
	grid .right.tg -row 4 -column 0 -sticky swen
	grid .right.tb -row 5 -column 0 -sticky swen

	grid .top.tl -row 1 -column 0 -sticky swen
	grid .top.ts -row 1 -column 2 -sticky swen
	grid .top.tv -row 1 -column 3 -sticky swen
    }
}







Changes to demos/matrix.tcl.
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
    }
}






|
|
|




<






1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
def effect_matrix {
    label RotMatrix
    setup {
	scale .left.s \
	    -from -180 -to 180 -resolution 0.01 \
	    -orient vertical \
	    -command [list ::apply {{theangle} {
		set s [expr {sin($theangle * 0.017453292519943295769236907684886)}]
		set c [expr {cos($theangle * 0.017453292519943295769236907684886)}]
		set matrix [list \
				[list $c           $s 0] \
				[list [expr {-$s}] $c 0] \
				[list $s           $s 1]]

		show_image [crimp matrix [base] $matrix]
	    }}]

	pack .left.s -side left -fill both -expand 1
    }
}
Changes to demos/psych.tcl.
1
2
3


4

5
6

7
8

9
10
11
12
13
14
def effect_psychedelia {
    label Psychedelia
    setup {


	proc ::P {} {

	    show_image [crimp psychedelia 320 240 100]
	    set ::PX [after 100 ::P]

	}
	::P

    }
    shutdown {
	after cancel $::PX
	unset ::PX
    }
}



>
>
|
>

|
>

|
>


|
<


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

17
18
def effect_psychedelia {
    label Psychedelia
    setup {
	variable token

	proc next {} {
	    variable token
	    show_image [crimp psychedelia 320 240 100]
	    set token [after 100 DEMO::next]
	    return
	}

	next
    }
    shutdown {
	after cancel $token

    }
}
Changes to demos/rehsv.tcl.
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
    }
}



|
>
>

<
<
|
<
|
|
<

<
|
<
<
|
|
>
>
|
|

>

|
>
>
|
|

>

|
>
>
|
|

>

>
>
>
>
>
>

<
<
|
>
>



|
|
|
|
>
>
>

|
|
|





>
|
|

>
|
|
<
<
<
<
<
<
<


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
def effect_rehsv {
    label {Change HSV}
    setup {
	variable hsvbase [crimp convert 2hsv [base]]
	variable ghg 1 ; variable gsg 1 ; variable gvg 1
	variable ghb 0 ; variable gsb 0 ; variable gvb 0



	variable th [crimp table gainw $ghg $ghb] ; variable mh [crimp map gainw $ghg $ghb]

	variable ts [crimp table gain  $gsg $gsb] ; variable ms [crimp map gain  $gsg $gsb]
	variable tv [crimp table gain  $gvg $gvb] ; variable mv [crimp map gain  $gvg $gvb]



	variable mask [lindex [crimp split [base]] end]



	proc H {args} {
	    variable ghb
	    variable ghg
	    variable th [crimp table gainw $ghg $ghb]
	    variable mh [crimp map   gainw $ghg $ghb]
	    UPDATE
	    return
	}
	proc S {args} {
	    variable gsb
	    variable gsg
	    variable ts [crimp table gain $gsg $gsb]
	    variable ms [crimp map   gain $gsg $gsb]
	    UPDATE
	    return
	}
	proc V {args} {
	    variable gvb
	    variable gvg
	    variable tv [crimp table gain $gvg $gvb]
	    variable mv [crimp map   gain $gvg $gvb]
	    UPDATE
	    return
	}
	proc UPDATE {} {
	    variable mh
	    variable ms
	    variable mv
	    variable hsvbase
	    variable mask



	    show_image [crimp setalpha \
			    [crimp convert 2rgb [crimp remap $hsvbase $mh $ms $mv]] \
			    $mask]
	    return
	}

	scale .left.hg -variable ::DEMO::ghg -from -10 -to 10  -resolution 0.01 -orient vertical -command ::DEMO::H
	scale .left.sg -variable ::DEMO::gsg -from -10 -to 10  -resolution 0.01 -orient vertical -command ::DEMO::S
	scale .left.vg -variable ::DEMO::gvg -from -10 -to 10  -resolution 0.01 -orient vertical -command ::DEMO::V

	scale .left.hb -variable ::DEMO::ghb -from 0 -to 255 -resolution 1    -orient vertical -command ::DEMO::H
	scale .left.sb -variable ::DEMO::gsb -from 0 -to 255 -resolution 1    -orient vertical -command ::DEMO::S
	scale .left.vb -variable ::DEMO::gvb -from 0 -to 255 -resolution 1    -orient vertical -command ::DEMO::V

	plot  .left.ph -variable ::DEMO::th -title Hue
	plot  .left.ps -variable ::DEMO::ts -title Saturation
	plot  .left.pv -variable ::DEMO::tv -title Value

	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.sg -row 1 -column 0 -sticky sen
	grid .left.ps -row 1 -column 1 -sticky swen
	grid .left.sb -row 1 -column 2 -sticky sen

	grid .left.vg -row 2 -column 0 -sticky sen
	grid .left.pv -row 2 -column 1 -sticky swen
	grid .left.vb -row 2 -column 2 -sticky sen







    }
}
Changes to demos/solarize.tcl.
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
    }
}



|
|

|
|


|
|
|
|




<
<
<

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18



19
def op_solarize {
    label Solarize
    setup {
	variable threshold 256
	variable table     {}

	plot  .left.p -variable ::DEMO::table -title Threshold
	scale .left.s -variable ::DEMO::threshold \
	    -from 0 -to 256 \
	    -orient horizontal \
	    -command [list ::apply {{thethreshold} {
		variable table [crimp table solarize  $thethreshold]
		show_image     [crimp solarize [base] $thethreshold]
	    } ::DEMO}]

	grid .left.s -row 0 -column 0 -sticky swen
	grid .left.p -row 1 -column 0 -sticky swen
    }



}
Changes to demos/wavy.tcl.
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
    }
}



|
|
>
>
|



|
|
|

|
|
|





<
<
<

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23



24
def effect_wavy {
    label Wavy
    setup {
	proc W {args} {
	    variable wa
	    variable wb
	    variable wc
	    show_image [crimp wavy [base] $wa $wb $wc]
	    return
	}

	variable wa 1
	variable wb 1
	variable wc 1

	scale .left.wa -variable ::DEMO::wa -from -20 -to 20 -resolution 0.01 -orient vertical -command ::DEMO::W
	scale .left.wb -variable ::DEMO::wb -from -20 -to 20 -resolution 0.01 -orient vertical -command ::DEMO::W
	scale .left.wc -variable ::DEMO::wc -from -20 -to 20 -resolution 0.01 -orient vertical -command ::DEMO::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
    }



}