u02/star_tool: Allow setting spikes in ctor

This commit is contained in:
Simon Bruder 2023-05-16 16:40:27 +02:00
parent f482d0a951
commit 18da3567cc
2 changed files with 7 additions and 3 deletions

View file

@ -26,7 +26,10 @@ std::vector<std::pair<float, float>> 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;
};

View file

@ -41,8 +41,9 @@ std::vector<std::pair<float, float>> 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) {