diff --git a/u02/include/star_tool.h b/u02/include/star_tool.h index 2f60bbb..eb1160f 100644 --- a/u02/include/star_tool.h +++ b/u02/include/star_tool.h @@ -26,7 +26,10 @@ std::vector> star(int n, float r1, float r2, int x = 0, class star_tool : public tool_base { public: - star_tool(canvas_buffer &canvas); + // Initialize a new star tool. + // It can draw stars with arbitrary number of spikes (however, at least 2). + // The preview is hard coded to 5 spikes. + star_tool(canvas_buffer &canvas, int spikes = 5); void draw(int x0, int y0, int x1, int y1); @@ -37,6 +40,6 @@ public: void set_radius_factor(int radius_factor); private: - int spikes = 5; + int spikes; float radius_factor = 1.0 / 3.0; }; diff --git a/u02/src/star_tool.cpp b/u02/src/star_tool.cpp index 1e6b19f..fb9bd72 100644 --- a/u02/src/star_tool.cpp +++ b/u02/src/star_tool.cpp @@ -41,8 +41,9 @@ std::vector> star(int n, float r1, float r2, int x, base_angle); } -star_tool::star_tool(canvas_buffer &canvas) : tool_base(canvas) { +star_tool::star_tool(canvas_buffer &canvas, int spikes) : tool_base(canvas) { shape = TS_STAR; + set_spikes(spikes); } void star_tool::draw(int x0, int y0, int x1, int y1) {