diff --git a/core/math/2d/geometry/goost_geometry_2d.cpp b/core/math/2d/geometry/goost_geometry_2d.cpp index 8060bb42..a2f8cdf2 100644 --- a/core/math/2d/geometry/goost_geometry_2d.cpp +++ b/core/math/2d/geometry/goost_geometry_2d.cpp @@ -513,7 +513,7 @@ Vector GoostGeometry2D::pixel_line(const Point2i &p_start, const Point2 // "A Fast Bresenham Type Algorithm For Drawing Circles" by John Kennedy: // https://web.engr.oregonstate.edu/~sllu/bcircle.pdf // -Vector GoostGeometry2D::pixel_circle(const Point2i &p_origin, int p_radius) { +Vector GoostGeometry2D::pixel_circle(int p_radius, const Point2i &p_origin) { ERR_FAIL_COND_V(p_radius < 0, Vector()); Vector circle; diff --git a/core/math/2d/geometry/goost_geometry_2d.h b/core/math/2d/geometry/goost_geometry_2d.h index 494148fa..0048f0e6 100644 --- a/core/math/2d/geometry/goost_geometry_2d.h +++ b/core/math/2d/geometry/goost_geometry_2d.h @@ -44,7 +44,7 @@ class GoostGeometry2D { static Vector circle(real_t p_radius, real_t p_max_error = 0.25); static Vector pixel_line(const Point2i &p_start, const Point2i &p_end); - static Vector pixel_circle(const Point2i &p_origin, int p_radius); + static Vector pixel_circle(int p_radius, const Point2i &p_origin = Point2i(0, 0)); static Vector polyline_to_pixels(const Vector &p_points); static Vector polygon_to_pixels(const Vector &p_points); }; diff --git a/core/math/2d/geometry/goost_geometry_2d_bind.cpp b/core/math/2d/geometry/goost_geometry_2d_bind.cpp index 07027cd6..64a09ebe 100644 --- a/core/math/2d/geometry/goost_geometry_2d_bind.cpp +++ b/core/math/2d/geometry/goost_geometry_2d_bind.cpp @@ -164,8 +164,8 @@ Vector _GoostGeometry2D::pixel_line(const Point2 &p_start, const Point2 return ret; } -Vector _GoostGeometry2D::pixel_circle(const Point2 &p_origin, int p_radius) const { - const Vector &circle = GoostGeometry2D::pixel_circle(p_origin, p_radius); +Vector _GoostGeometry2D::pixel_circle(int p_radius, const Point2 &p_origin) const { + const Vector &circle = GoostGeometry2D::pixel_circle(p_radius, p_origin); Vector ret; for (int i = 0; i < circle.size(); ++i) { ret.push_back(circle[i]); @@ -222,8 +222,9 @@ void _GoostGeometry2D::_bind_methods() { ClassDB::bind_method(D_METHOD("regular_polygon", "sides", "size"), &_GoostGeometry2D::regular_polygon); ClassDB::bind_method(D_METHOD("circle", "radius", "max_error"), &_GoostGeometry2D::circle, DEFVAL(0.25)); + ClassDB::bind_method(D_METHOD("pixel_line", "start", "end"), &_GoostGeometry2D::pixel_line); - ClassDB::bind_method(D_METHOD("pixel_circle", "origin", "radius"), &_GoostGeometry2D::pixel_circle); + ClassDB::bind_method(D_METHOD("pixel_circle", "radius", "origin"), &_GoostGeometry2D::pixel_circle, DEFVAL(Vector2(0, 0))); ClassDB::bind_method(D_METHOD("polyline_to_pixels", "points"), &_GoostGeometry2D::polyline_to_pixels); ClassDB::bind_method(D_METHOD("polygon_to_pixels", "points"), &_GoostGeometry2D::polygon_to_pixels); } diff --git a/core/math/2d/geometry/goost_geometry_2d_bind.h b/core/math/2d/geometry/goost_geometry_2d_bind.h index 60e987e6..935bf93d 100644 --- a/core/math/2d/geometry/goost_geometry_2d_bind.h +++ b/core/math/2d/geometry/goost_geometry_2d_bind.h @@ -48,7 +48,7 @@ class _GoostGeometry2D : public Object { Vector circle(real_t p_radius, real_t p_max_error) const; Vector pixel_line(const Point2 &p_start, const Point2 &p_end) const; - Vector pixel_circle(const Point2 &p_origin, int p_radius) const; + Vector pixel_circle(int p_radius, const Point2 &p_origin = Point2(0, 0)) const; Vector polyline_to_pixels(const Vector &p_points) const; Vector polygon_to_pixels(const Vector &p_points) const; diff --git a/doc/GoostGeometry2D.xml b/doc/GoostGeometry2D.xml index 517f713b..31411e4f 100644 --- a/doc/GoostGeometry2D.xml +++ b/doc/GoostGeometry2D.xml @@ -143,9 +143,9 @@ - + - + Returns an array of 2D-dimensional raster coordinates approximating a circle using a Bresenham type algorithm. diff --git a/tests/project/goost/core/math/2d/geometry/test_geometry_2d.gd b/tests/project/goost/core/math/2d/geometry/test_geometry_2d.gd index 79b3f8d7..6212a413 100644 --- a/tests/project/goost/core/math/2d/geometry/test_geometry_2d.gd +++ b/tests/project/goost/core/math/2d/geometry/test_geometry_2d.gd @@ -188,7 +188,7 @@ func test_pixel_line(): func test_pixel_circle(): - var circle = GoostGeometry2D.pixel_circle(Vector2(0, 0), 16) + var circle = GoostGeometry2D.pixel_circle(16) # for i in circle.size(): # gut.p("%s: %s" % [i, circle[i]]) assert_eq(circle.size(), 96)