Skip to content

Commit

Permalink
Support linewidth attribute in PIL back end
Browse files Browse the repository at this point in the history
- bump requirement for pillow>=9.2.0
  • Loading branch information
ejeschke committed Jul 27, 2023
1 parent 8bfac7b commit 8b24d4b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
4 changes: 4 additions & 0 deletions doc/WhatsNew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ What's New
Ver 5.0.0 (unreleased)
======================
- Add Contrast and Brightness adjustments in "Preferences" plugin
- Modifications to PIL backend

- support pillow v10.0
- now supports linewidth attribute

Ver 4.1.0 (2022-06-30)
======================
Expand Down
9 changes: 5 additions & 4 deletions ginga/pilw/CanvasRenderPil.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ def __init__(self, renderer, viewer, surface):
self.font = None

def set_line_from_shape(self, shape):
# TODO: support line width and style
# TODO: support line style
alpha = getattr(shape, 'alpha', 1.0)
color = getattr(shape, 'color', 'black')
self.pen = self.cr.get_pen(color, alpha=alpha)
linewidth = getattr(shape, 'linewidth', 1)
self.pen = self.cr.get_pen(color, linewidth=linewidth, alpha=alpha)

def set_fill_from_shape(self, shape):
fill = getattr(shape, 'fill', False)
Expand Down Expand Up @@ -71,8 +72,8 @@ def initialize_from_shape(self, shape, line=True, fill=True, font=True):
self.set_font_from_shape(shape)

def set_line(self, color, alpha=1.0, linewidth=1, style='solid'):
# TODO: support line width and style
self.pen = self.cr.get_pen(color, alpha=alpha)
# TODO: support line style
self.pen = self.cr.get_pen(color, linewidth=linewidth, alpha=alpha)

def set_fill(self, color, alpha=1.0):
if color is None:
Expand Down
10 changes: 6 additions & 4 deletions ginga/pilw/PilHelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,21 @@ def circle(self, pt, radius, pen, brush):
if (brush is not None) and brush.fill:
self.ctx.ellipse(((x - radius, y - radius),
(x + radius, y + radius)),
fill=brush.color, outline=pen.color)
fill=brush.color, outline=pen.color,
width=pen.linewidth)
else:
self.ctx.ellipse(((x - radius, y - radius),
(x + radius, y + radius)),
outline=pen.color)
outline=pen.color, width=pen.linewidth)

def polygon(self, points, pen, brush):
points = self._cvt_points(points)

if (brush is not None) and brush.fill:
self.ctx.polygon(points, fill=brush.color, outline=pen.color)
self.ctx.polygon(points, fill=brush.color, outline=pen.color,
width=pen.linewidth)
else:
self.ctx.polygon(points, outline=pen.color)
self.ctx.polygon(points, outline=pen.color, width=pen.linewidth)

def path(self, points, pen):
points = self._cvt_points(points)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ install_requires =
numpy>=1.14
qtpy>=2.0.1
astropy>=3.2
pillow>=6.2.1
pillow>=9.2.0
importlib-metadata ; python_version == '3.7'
setup_requires = setuptools_scm

Expand Down

0 comments on commit 8b24d4b

Please sign in to comment.