]> git.plutz.net Git - viper/blob - plugins/f_blur+sharpen.py
updated copyleft notice
[viper] / plugins / f_blur+sharpen.py
1 #encoding: utf-8
2 #Copyright 2010 Thomas Kretzer, Paul Hänsch
3
4 #This file is part of Viper. 
5
6 #Viper is free software: you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation, either version 3 of the License, or
9 #(at your option) any later version.
10
11 #Viper is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #GNU General Public License for more details.
15
16 #You should have received a copy of the GNU General Public License
17 #along with Viper.  If not, see <http://www.gnu.org/licenses/>
18
19 from plugin import *
20
21 class F_Blur(F_Plugin):
22     def build_dialog(self):
23         self.sharpen = StringVar(value = '+')
24         self.edges = StringVar(value = '+')
25
26         self.subgets['f_filter'] = LabelFrame(self, text = 'Filter')
27         self.subgets['f_filter'].pack(side = TOP, expand = True, fill = BOTH)
28         self.subgets['r_planes'] = Radiobutton(self.subgets['f_filter'], text = 'Flat areas', variable = self.edges, value = '+')
29         self.subgets['r_planes'].pack(side = TOP, anchor = W)
30         self.subgets['r_edges'] = Radiobutton(self.subgets['f_filter'], text = 'Edges', variable = self.edges, value = '-')
31         self.subgets['r_edges'].pack(side = TOP, anchor = W)
32
33         self.subgets['f_label'] = Frame(self)
34         self.subgets['f_label'].pack(side = LEFT, anchor = E, fill = X)
35         self.subgets['f_spin'] = Frame(self)
36         self.subgets['f_spin'].pack(side = LEFT, anchor = W, expand = True, fill = X)
37
38         self.subgets['l_radius'] = Label(self.subgets['f_label'], text = 'Radius:')
39         self.subgets['l_radius'].pack(side = TOP, anchor = E)
40         self.subgets['l_strength'] = Label(self.subgets['f_label'], text = 'Strength:')
41         self.subgets['l_strength'].pack(side = TOP, anchor = E)
42         self.subgets['l_threshold'] = Label(self.subgets['f_label'], text = 'Threshold:')
43         self.subgets['l_threshold'].pack(side = TOP, anchor = E)
44
45         self.subgets['s_radius'] = Spinbox(self.subgets['f_spin'], from_ = 0.0, to = 5.0, wrap = False, increment = .1, width = 4, justify = RIGHT)
46         self.subgets['s_radius'].delete(0, END)
47         self.subgets['s_radius'].insert(0, '1.0')
48         self.subgets['s_radius'].pack(side = TOP, anchor = W)
49         
50         self.subgets['s_strength'] = Spinbox(self.subgets['f_spin'], from_ = 0.0, to = 1.0, wrap = False, increment = .1, width = 4, justify = RIGHT)
51         self.subgets['s_strength'].delete(0, END)
52         self.subgets['s_strength'].insert(0, '0.0')
53         self.subgets['s_strength'].pack(side = TOP, anchor = W)
54
55         self.subgets['s_threshold'] = Spinbox(self.subgets['f_spin'], from_ = 0, to = 30, wrap = True, increment = 1, width = 4, justify = RIGHT)
56         self.subgets['s_threshold'].delete(0, END)
57         self.subgets['s_threshold'].insert(0, 0)
58         self.subgets['s_threshold'].pack(side = TOP, anchor = W)
59         
60     def name(self):
61         return 'Blur'
62
63     def subcommand(self):
64         return ['-vf-add', 'smartblur=' + str(self.subgets['s_radius'].get()) + ':' + self.sharpen.get() + str(self.subgets['s_strength'].get()) + ':' + self.edges.get() + str(self.subgets['s_threshold'].get())]
65
66 class F_Sharpen(F_Plugin):
67     def build_dialog(self):
68         self.sharpen = StringVar(value = '-')
69         self.edges = StringVar(value = '+')
70
71         self.subgets['f_filter'] = LabelFrame(self, text = 'Filter')
72         self.subgets['f_filter'].pack(side = TOP, expand = True, fill = BOTH)
73         self.subgets['r_planes'] = Radiobutton(self.subgets['f_filter'], text = 'Flat areas', variable = self.edges, value = '+')
74         self.subgets['r_planes'].pack(side = TOP, anchor = W)
75         self.subgets['r_edges'] = Radiobutton(self.subgets['f_filter'], text = 'Edges', variable = self.edges, value = '-')
76         self.subgets['r_edges'].pack(side = TOP, anchor = W)
77
78         self.subgets['f_label'] = Frame(self)
79         self.subgets['f_label'].pack(side = LEFT, anchor = E, fill = X)
80         self.subgets['f_spin'] = Frame(self)
81         self.subgets['f_spin'].pack(side = LEFT, anchor = W, expand = True, fill = X)
82
83         self.subgets['l_radius'] = Label(self.subgets['f_label'], text = 'Radius:')
84         self.subgets['l_radius'].pack(side = TOP, anchor = E)
85         self.subgets['l_strength'] = Label(self.subgets['f_label'], text = 'Strength:')
86         self.subgets['l_strength'].pack(side = TOP, anchor = E)
87         self.subgets['l_threshold'] = Label(self.subgets['f_label'], text = 'Threshold:')
88         self.subgets['l_threshold'].pack(side = TOP, anchor = E)
89
90         self.subgets['s_radius'] = Spinbox(self.subgets['f_spin'], from_ = 0.0, to = 5.0, wrap = False, increment = .1, width = 4, justify = RIGHT)
91         self.subgets['s_radius'].delete(0, END)
92         self.subgets['s_radius'].insert(0, '1.0')
93         self.subgets['s_radius'].pack(side = TOP, anchor = W)
94         
95         self.subgets['s_strength'] = Spinbox(self.subgets['f_spin'], from_ = 0.0, to = 1.0, wrap = False, increment = .1, width = 4, justify = RIGHT)
96         self.subgets['s_strength'].delete(0, END)
97         self.subgets['s_strength'].insert(0, '0.0')
98         self.subgets['s_strength'].pack(side = TOP, anchor = W)
99
100         self.subgets['s_threshold'] = Spinbox(self.subgets['f_spin'], from_ = 0, to = 30, wrap = True, increment = 1, width = 4, justify = RIGHT)
101         self.subgets['s_threshold'].delete(0, END)
102         self.subgets['s_threshold'].insert(0, 0)
103         self.subgets['s_threshold'].pack(side = TOP, anchor = W)
104         
105     def name(self):
106         return 'Sharpen'
107
108     def subcommand(self):
109         return ['-vf-add', 'smartblur=' + str(self.subgets['s_radius'].get()) + ':' + self.sharpen.get() + str(self.subgets['s_strength'].get()) + ':' + self.edges.get() + str(self.subgets['s_threshold'].get())]