Debian Codegraph @

fltk/test/arc.py

raw symbols SCIP
1 #
2 # "$Id: arc.py 535 2020-10-30 10:43:46Z andreasheld $"
3 #
4 # Arc drawing program for pyFLTK the Python bindings
5 # for the Fast Light Tool Kit (FLTK).
6 # Illustrates the use of the Fl_Widget base class.
7 #
8 # FLTK copyright 1998-1999 by Bill Spitzak and others.
9 # pyFLTK copyright 2003 by Andreas Held and others.
10 #
11 # This library is free software you can redistribute it and/or
12 # modify it under the terms of the GNU Library General Public
13 # License, version 2.0 as published by the Free Software Foundation.
14 #
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Library General Public License for more details.
19 #
20 # You should have received a copy of the GNU Library General Public
21 # License along with this library if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 # USA.
24 #
25 # Please report all bugs and problems to "[email protected]".
26 #
27
28 # Arc drawing test program for the Fast Light Tool Kit (FLTK).
29
30 from fltk import *
31 import sys
32 if sys.version > '3':
33 long = int
34
35 args = [140, 140, 50, 0, 360, 0]
36 name = ["X", "Y", "R", "start", "end", "rotate"]
37 d = None
38
39 class Drawing(Fl_Widget):
40
41 def __init__(self, X, Y, W, H, L):
42 Fl_Widget.__init__(self, X, Y, W, H, L)
43
44 def draw(self):
45 global args
46 try:
47 xpos = self.x()
48 ypos = self.y()
49 w = self.w()
50 h = self.h()
51 fl_push_clip(xpos,ypos,w,h)
52 fl_color(FL_DARK3)
53 fl_rectf(xpos,ypos,w,h)
54 fl_push_matrix()
55 if args[5]:
56 fl_translate(xpos+w/2.0, ypos+h/2.0)
57 fl_rotate(args[5])
58 fl_translate(-(xpos+w/2.0), -(ypos+h/2.0))
59 fl_color(FL_WHITE)
60 fl_translate(xpos,ypos)
61 fl_begin_complex_polygon()
62 fl_arc(args[0],args[1],args[2],args[3],args[4])
63 fl_gap()
64 fl_arc(140,140,20,0,-360)
65 fl_end_complex_polygon()
66 fl_color(FL_RED)
67 fl_begin_line()
68 fl_arc(args[0],args[1],args[2],args[3],args[4])
69 fl_end_line()
70 fl_pop_matrix()
71 fl_pop_clip()
72 except:
73 print('uncaught!', sys.exc_info()[0], sys.exc_info()[1])
74 return None
75
76
77
78 def slider_cb(ptr, v):
79 global d
80 args[int(v)] = ptr.value()
81 d.redraw()
82
83
84
85 window = Fl_Window(300,500)
86 d = Drawing(10,10,280,280, "test")
87 y = 300
88 n = 0
89 s = [None,None,None,None,None,None]
90 while n < 6:
91 s[n] = Fl_Hor_Value_Slider(50,y,240,25,name[n])
92 y = y+25
93 if n<3:
94 s[n].minimum(0)
95 s[n].maximum(300)
96 else:
97 if n==5:
98 s[n].minimum(0)
99 s[n].maximum(360)
100 else:
101 s[n].minimum(-360)
102 s[n].maximum(360)
103 s[n].step(1)
104 s[n].value(args[n])
105 s[n].align(FL_ALIGN_LEFT)
106 s[n].callback(slider_cb, n)
107 n = n+1
108
109
110 window.end()
111 #window.show(len(sys.argv),sys.argv)
112 #window.show()
113 window.show(sys.argv)
114
115 d.redraw()
116 Fl.run()
117
118