1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
5 # Jockey is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
10 # Jockey is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 from pychart_types import *
27 "bgcolor" : (color.T, color.white, "The background color."),
28 "line_style": (line_style.T, line_style.default,
29 pychart_util.line_desc),
30 "line_interval": (NumType, 3,
31 "The interval between successive stitch lines.")
34 class T(chart_object.T):
35 __doc__ = fill_style_doc.doc
37 ##AUTOMATICALLY GENERATED
38 ##END AUTOMATICALLY GENERATED
40 s = name_table().lookup(self)
43 return "<fillstyle: bg=%s line=%s interval=%s>" % \
44 (self.bgcolor, self.line_style, self.line_interval)
47 """This class just fills the region with solid background color.
48 Attributes line_style and line_interval are ignored."""
49 def draw(self, can, x1, y1, x2, y2):
53 "This class fills the region with diagonal lines."
55 def draw(self, can, x1, y1, x2, y2):
56 line_width = self.line_style.width
57 interval = self.line_interval * 1.414
62 len = max(y2 - y1, x2 - x1)
65 can.line(self.line_style, curx, y1, curx+len, y1+len)
69 """Fills the region with diagonal lines, but tilted in the opposite
70 direction from fill_style.Diag."""
71 def draw(self, can, x1, y1, x2, y2):
72 line_width = self.line_style.width
73 interval = self.line_interval * 1.414
78 len = max(y2 - y1, x2 - x1)
80 while curx < x2 + len:
81 can.line(self.line_style, curx, y1, curx-len, y1+len)
85 "Fills the region with vertical lines"
86 def draw(self, can, x1, y1, x2, y2):
87 interval = self.line_interval
90 can.line(self.line_style, curx, y1, curx, y2)
94 "Fills the region with horizontal lines"
95 def draw(self, can, x1, y1, x2, y2):
96 interval = self.line_interval
99 can.line(self.line_style, x1, cury, x2, cury)
103 "Fills the region with horizontal and vertical lines."
104 def draw(self, can, x1, y1, x2, y2):
105 interval = self.line_interval
108 can.line(self.line_style, x1, cury, x2, cury)
112 can.line(self.line_style, curx, y1, curx, y2)
116 "Fills the region with horizontal wavy lines."
117 def draw(self, can, x1, y1, x2, y2):
122 line_width = nscale(self.line_style.width)
123 interval = nscale(self.line_interval)
125 can.set_line_style(self.line_style)
133 can.moveto(curx, cury)
135 can.lineto(curx + half, cury + half)
136 can.lineto(curx + interval, cury)
142 """Fills the region with vertical wavy lines."""
143 def draw(self, can, x1, y1, x2, y2):
148 line_width = nscale(self.line_style.width)
149 interval = nscale(self.line_interval)
151 can.set_line_style(self.line_style)
159 can.moveto(curx, cury)
161 can.lineto(curx + half, cury + half)
162 can.lineto(curx, cury + interval)
168 """Fills the region with a series of short line segments."""
169 def draw(self, can, x1, y1, x2, y2):
170 interval = nscale(self.line_interval)
178 can.line(self.line_style, curx, cury, curx+interval/2.0, cury)
179 curx += interval * 1.5
185 color_standards = object_set.T()
186 grayscale_standards = object_set.T()
188 def _intern_both(style):
189 global color_standards, grayscale_standards
190 color_standards.add(style)
191 grayscale_standards.add(style)
194 def _intern_color(style):
195 global color_standards, grayscale_standards
196 color_standards.add(style)
199 def _intern_grayscale(style):
200 global color_standards, grayscale_standards
201 grayscale_standards.add(style)
204 black = _intern_both(Plain(bgcolor=color.gray_scale(0.0), line_style=None))
206 red = _intern_color(Plain(bgcolor=color.red))
207 darkseagreen = _intern_color(Plain(bgcolor=color.darkseagreen))
208 blue = _intern_color(Plain(bgcolor=color.blue))
209 aquamarine1 = _intern_color(Plain(bgcolor=color.aquamarine1))
210 gray70 = _intern_both(Plain(bgcolor=color.gray70, line_style=None))
211 brown = _intern_color(Plain(bgcolor=color.brown))
212 darkorchid = _intern_color(Plain(bgcolor=color.darkorchid))
213 diag = _intern_both(Diag(line_style=line_style.T(cap_style=2)))
214 green = _intern_color(Plain(bgcolor=color.green))
215 gray50 = _intern_both(Plain(bgcolor=color.gray50, line_style=None))
216 white = _intern_both(Plain(bgcolor=color.gray_scale(1.0), line_style=None))
217 goldenrod = _intern_color(Plain(bgcolor=color.goldenrod))
218 rdiag = _intern_both(Rdiag(line_style=line_style.T(cap_style=2)))
219 vert = _intern_both(Vert(line_interval=1.8))
221 gray30 = _intern_both(Plain(bgcolor=color.gray30, line_style=None))
222 gray20 = _intern_both(Plain(bgcolor=color.gray20, line_style=None))
223 gray10 = _intern_both(Plain(bgcolor=color.gray10, line_style=None))
224 diag2 = _intern_both(Diag(line_style=line_style.T(width=3, cap_style=2),
226 rdiag2 = _intern_both(Rdiag(line_style=line_style.T(width=3, cap_style=2),
228 yellow = _intern_color(Plain(bgcolor=color.yellow))
229 diag3 = _intern_both(Diag(line_style=line_style.T(width=3, color=color.gray50, cap_style=2),
231 horiz = _intern_both(Horiz(line_interval=1.8))
232 gray90 = _intern_both(Plain(bgcolor=color.gray90, line_style=None))
233 rdiag3 = _intern_both(Rdiag(line_style=line_style.T(width=3,
238 wave = _intern_both(Wave(line_style=line_style.T(cap_style=2, join_style=1)))
239 vwave = _intern_both(Vwave(line_style=line_style.T(cap_style=2, join_style=1)))
240 stitch = _intern_both(Stitch(line_style=line_style.T(cap_style=2, join_style=1)))
241 lines = _intern_both(Lines(line_style=line_style.T()))
243 diag_fine = _intern_both(Diag(line_style=line_style.T(width=0.75,cap_style=2),
244 line_interval = 1.5))
245 diag2_fine = _intern_both(Diag(line_style=line_style.T(width=0.75, cap_style=2),
247 diag3_fine = _intern_both(Diag(line_style=line_style.T(width=0.75,
248 color = color.gray50,
251 rdiag_fine = _intern_both(Rdiag(line_style=line_style.T(width=0.75,cap_style=2),
252 line_interval = 1.5))
253 rdiag2_fine = _intern_both(Rdiag(line_style=line_style.T(width=0.75, cap_style=2),
255 rdiag3_fine = _intern_both(Rdiag(line_style=line_style.T(width=0.75,
256 color = color.gray50,
260 horiz_fine = _intern_both(Horiz(line_interval=1.5))
261 vert_fine = _intern_both(Vert(line_interval=1.5))
264 # Fill styles for color charts.
271 global standards, _name_table
273 standards = color_standards
275 standards = grayscale_standards
281 _name_table = pychart_util.symbol_lookup_table(globals(), standards)
285 theme.add_reinitialization_hook(init)