Fix the rendering of polygons in basecore2d-based backends#987
Conversation
This: - consistently uses Nx2 numpy arrays to store path points - doesn't create a new subpath after a LINES function A driveby fix gives a default implementation for show_text_at_point().
| if func == POINT: | ||
| self.draw_subpath(mode) | ||
| self.add_point_to_subpath(args) | ||
| self.add_point_to_subpath(args.reshape(1, 2)) |
There was a problem hiding this comment.
Is it guaranteed that args will always be a NumPy array? I see some examples that are calling line_set with lists of tuples, for example here:
enable/docs/source/kiva_tutorial/tutorial_advanced.py
Lines 226 to 228 in a71a938
(Same question for LINE below.)
There was a problem hiding this comment.
I guess calling the np.reshape function instead of the method might be a way to fix this.
There was a problem hiding this comment.
The values for args are populated from move_to, line_to, etc. which should be populating with arrays, but you're right it looks like there might be some places where this may not be absolutely guaranteed (eg. lines and line_set docstring specifies Nx2 arrays, but probably gets used with lists of points).
Possibly can move the reshaping there as well.
There was a problem hiding this comment.
I fixed the one case I could see where lines might add non-array object to the sub-path args, plus a second issue where closing the path could error or give the wrong results.
mdickinson
left a comment
There was a problem hiding this comment.
LGTM besides the possible .reshape on non-arrays issue.
* Fix the rendering of polygons in basecore2d-based backends This: - consistently uses Nx2 numpy arrays to store path points - doesn't create a new subpath after a LINES function A driveby fix gives a default implementation for show_text_at_point(). * Clean-up comments. * Fix some unused imports. * Some of the unused imports are in fact used. * Improve the situation of line_state_equal a bit. * Ensure all subpath arguments are numpy arrays.
* Use the "sphinx-copybutton" extension in documentation (#948) * DOC: Use the sphinx-copybutton extension in documentation modified: ci/edmtool.py modified: docs/source/conf.py modified: enable/__init__.py * Update ci/edmtool.py * Get things working on wxPython again (#950) Addresses these warnigns/exceptions: - TypeError: BitmapFromImage() got an unexpected keyword argument 'depth' - AttributeError: 'PaintDC' object has no attribute 'BeginDrawing' - wxPyDeprecationWarning: Call to deprecated item EmptyImage. Use :class:`Image` instead. image = wx.EmptyImage(*sz) - wxPyDeprecationWarning: Call to deprecated item BitmapFromImage. Use :class:`wx.Bitmap` instead bmp = wx.BitmapFromImage(image, depth=-1) See https://forums.wxwidgets.org/viewtopic.php?t=39930 why the Begin/EndDrawing calls can simply be removed. Related issues: #798 and #531 * Add SWIG to pyproject.toml build dependencies (#954) * Experiment with installing SWIG from PyPI * Update the EDM-based workflow * Remove restriction on SWIG version * Add Cython back as a development dependency; remove verify_swig_install * Remove generated C++ file. (#958) * Fix Kiva Quartz backend string encoding (#966) * Add regression test for Enable #964. * Properly decode strings in Kiva Quartz font code. * Properly guard against running Quartz tests on non-Mac systems. * Ensure Wx Quartz test terminates. * Make test success externally visible. * Fix tests, use UTF-8. * Add a github workflow that publishes to sdists to PyPI on release (#967) * Add a github workflow that publishes to sdists to PyPI on release. * Use build to build the sdist. * Take into account all font features when drawing SVG text. (#980) * Fix Quartz font rendering (#978) * Use font family in quartz when no font name given. * Render quartz text with fill color rather than stroke color. * Fix `SCRIPT` font family in Kiva (#975) * Add a test for #971 This should fail CI. * Fix bug and clean-up style. * Correct first point and orientation of Kiva QPainter arcs (#970) * Correct first point and orientation of Kiva QPainter arcs. This fixes #962 but not #960. * Update kiva/qpainter.py * Render font families better in QPainter backend (#973) * Fall back to kiva.fonttools if Qt can't come up with a font name. * Add a comment about setFamilies() * Fix WEIGHT_EXTRAHEAVY on Qt6 (#990) Some changes to tests to make sure eveything is tested correctly. * Fix the rendering of polygons in basecore2d-based backends (#987) * Fix the rendering of polygons in basecore2d-based backends This: - consistently uses Nx2 numpy arrays to store path points - doesn't create a new subpath after a LINES function A driveby fix gives a default implementation for show_text_at_point(). * Clean-up comments. * Fix some unused imports. * Some of the unused imports are in fact used. * Improve the situation of line_state_equal a bit. * Ensure all subpath arguments are numpy arrays. * Ensure all backends implement `arc_to` and `quad_curve_to` (#988) * Ensure all backends implement arc_to and quad_curve_to. * Fix 'infomration' typo in comments in multiple files. * Fixes suggested from PR review. Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com> Co-authored-by: Brecht Machiels <brecht@mos6581.org> Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
This:
LINESfunction (so consecutive arc, curve, etc. commands add to the subpath).A drive-by fix gives a default implementation for
show_text_at_point().Image from the benchmark suite (for SVG):

Fixes #986.