Change line_to path method to behave like move_to for empty paths - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年02月06日 14:15:36 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年02月06日 21:43:56 +0100
commitdcc9ad4b8fbefbd762955b2ececcfd84228f8def (patch)
tree16b92db718c32fb8628b809e3796f05a82b15d00
parent4220a54f85c62a8ad9cb4652325bf4af8afa2390 (diff)
downloadgsl-shell-dcc9ad4b8fbefbd762955b2ececcfd84228f8def.tar.gz
Change line_to path method to behave like move_to for empty paths
Diffstat
-rw-r--r--agg-plot/lua-draw.cpp 5
-rw-r--r--doc/user-manual/graphics.rst 5
2 files changed, 9 insertions, 1 deletions
diff --git a/agg-plot/lua-draw.cpp b/agg-plot/lua-draw.cpp
index b9a3a13e..4148c3c8 100644
--- a/agg-plot/lua-draw.cpp
+++ b/agg-plot/lua-draw.cpp
@@ -147,7 +147,10 @@ path_cmd (draw::path *p, int _cmd, struct cmd_call_stack *s)
ps.move_to (s->f[0], s->f[1]);
break;
case CMD_LINE_TO:
- ps.line_to (s->f[0], s->f[1]);
+ if (ps.total_vertices() == 0)
+ ps.move_to (s->f[0], s->f[1]);
+ else
+ ps.line_to (s->f[0], s->f[1]);
break;
case CMD_CLOSE:
ps.close_polygon ();
diff --git a/doc/user-manual/graphics.rst b/doc/user-manual/graphics.rst
index b331f35c..443acfb2 100644
--- a/doc/user-manual/graphics.rst
+++ b/doc/user-manual/graphics.rst
@@ -658,6 +658,11 @@ Graphical Objects
.. method:: line_to(x, y)
Add a line into the path from the previous point to the specified (x, y) coordinates.
+ As a special case, if the path is empty, this method is equivalent to :meth:`~Path.move_to`.
+
+ .. hint::
+ If you want to define a polygonal line you don't need to use the :meth:`~Path.move_to` method for the first point.
+ Instead you can use the method :meth:`~Path.line_to` to add each point.
.. method:: close()
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月16日 03:26:10 +0000

AltStyle によって変換されたページ (->オリジナル) /