diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..7696ea2 Binary files /dev/null and b/.DS_Store differ diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..97c1779 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "macos-clang-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "/usr/bin/clang", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "macos-clang-x64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..bb9442e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "lldb", + "request": "launch", + "args": [], + "cwd": "/Users/katianawieser/libturtle/demo", + "program": "/Users/katianawieser/libturtle/demo/build/Debug/outDebug" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b9c6ac8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "C_Cpp_Runner.cCompilerPath": "clang", + "C_Cpp_Runner.cppCompilerPath": "clang++", + "C_Cpp_Runner.debuggerPath": "lldb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/demo/demo.cpp b/demo/demo.cpp index eca9fc1..e3d80f0 100644 --- a/demo/demo.cpp +++ b/demo/demo.cpp @@ -7,27 +7,73 @@ using namespace std; -void rect(Turtle& t, float width, float height) { +void rect(Turtle &t, float width, float height) +{ t.forward(width); t.right(90); + t.set_decor_stitch(3); t.forward(height); t.right(90); + t.set_decor_stitch(1); t.forward(width); t.right(90); + t.set_decor_stitch(2); t.forward(height); t.right(90); } +void penta(Turtle &t, float width) +{ + t.decor_on(0); + for (int i = 0; i < 5; i++) + { + t.set_decor_stitch(i); + t.forward(width); + t.left(72); + } +} + +void octa(Turtle &t, float width) +{ + + t.decor_on(0); + for (int i = 0; i < 8; i++) + { + if (i == 7) + { + t.decor_off(); + } + else + { + t.set_decor_stitch(i); + } + + t.forward(width); + t.left(45); + } +} -void meetTurtle() { +void meetTurtle() +{ Turtle t; - t.satinon(0.3); - t.pendown(); - rect(t, 20, 30); + // t.satinon(0.3); + + t.pendown(); + // t.forward(10); + // t.decor_on(5); + // t.decor_on(6); + + octa(t, 30); + // t.decor_on(4); + // rect(t, 30, 30); + + // penta(t, 50); + // t.forward(60); t.end(); t.save("demo.dst"); } -int main() { - meetTurtle(); +int main() +{ + meetTurtle(); } diff --git a/src/turtle.cpp b/src/turtle.cpp index 19f87d2..8ae4d63 100644 --- a/src/turtle.cpp +++ b/src/turtle.cpp @@ -20,17 +20,21 @@ Turtle::Turtle() pen_is_down_{false}, satin_is_on_{false}, satin_delta_{.5}, + decor_stitch_{0}, + decor_active_{false}, dir_{Point(1, 0)}, position_{Point(0, 0)}, density_error_{false}, - density_warning_{false} { + density_warning_{false} +{ embPattern_addThread( emb_, EmbThread{embColor_make(0, 0, 0), "Default color", "0"}); embPattern_changeColor(emb_, 1); } /** Destructor: The destructor calls the appropriate libembroidery cleanup. */ -Turtle::~Turtle() { +Turtle::~Turtle() +{ embPattern_free(emb_); } @@ -42,7 +46,8 @@ Turtle::~Turtle() { will be added at 2, 4, 6, 8, and 10. * When satin sttich is on, this sets the *width* of the satin stitch. */ -void Turtle::setStepSize(float step) { +void Turtle::setStepSize(float step) +{ stepsize_ = step; } @@ -50,24 +55,77 @@ void Turtle::setStepSize(float step) { * When satin stitch is on, the Turtle will move side to side, * creating the effect of a wider line of thread. */ -void Turtle::satinon(float delta) { +void Turtle::satinon(float delta) +{ satin_is_on_ = true; satin_delta_ = delta; + decor_off(); } /** Disables satin stitch mode. * When satin stitch is off, the Turtle will move in a straight * stitch line, using the current step size. */ -void Turtle::satinoff() { +void Turtle::satinoff() +{ satin_is_on_ = false; } +/* +Sets the decorative stitch to be drawn with the turtle, does NOT turn it on though +For first test would reccomend step size of 10 for highly visible stitches, + stepsize 2 is very small and it makes it hard to see the decorative stitches +Stitch Key + * 0: Arrow stitch + * 1: ZigZag stitch + * 2: Feather stitch + * 3: Blanket stitch + * 4: Leaf & Vine Stitch + * 5: Square Zag Stitch + * 6: Lightning Stitch +*/ +void Turtle::set_decor_stitch(int index) +{ + decor_stitch_ = index; +} + +/** + * Enables decorative stitches; sets stitch to stitch # passed in + * + * For first test would reccomend step size of 10 for highly visible stitches, + stepsize 2 is very small and it makes it hard to see the decorative stitches + + * Stitch Key + * 0: Arrow stitch + * 1: ZigZag stitch + * 2: Feather stitch + * 3: Blanket stitch + * 4: Leaf & Vine Stitch + * 5: Square Zag Stitch + * 6: Lightning Stitch + * + */ +void Turtle::decor_on(int index) +{ + decor_active_ = true; + decor_stitch_ = index; +} + +/** + * Disables all decorative stitches + * + */ +void Turtle::decor_off() +{ + decor_active_ = false; +} + /** Puts the turtle's pen down. * When the pen is down, the turtle will add stitches along any * path it follows. */ -void Turtle::pendown() { +void Turtle::pendown() +{ pen_is_down_ = true; } @@ -75,14 +133,16 @@ void Turtle::pendown() { * When the pen is up, the turtle will "jump" from one location * to another without adding any stitches. */ -void Turtle::penup() { +void Turtle::penup() +{ pen_is_down_ = false; } /** Returns the Turtle's current position. * The position is returned as a Point object. */ -Point Turtle::position() { +Point Turtle::position() +{ return position_; } @@ -92,7 +152,8 @@ Point Turtle::position() { * The turtle's direction is changed so that it is facing in the direction of * the Point `pos`. The turtle's location is not changed. */ -void Turtle::turntoward(const Point& pos) { +void Turtle::turntoward(const Point &pos) +{ Point delta = pos - position_; dir_ = delta.normalize(1); } @@ -102,7 +163,8 @@ void Turtle::turntoward(const Point& pos) { * the point `(x,y)`. The turtle's location is not changed. */ -void Turtle::turntoward(const float x, const float y) { +void Turtle::turntoward(const float x, const float y) +{ turntoward(Point(x, y)); } @@ -110,7 +172,8 @@ void Turtle::turntoward(const float x, const float y) { * The direction is set to the (normalized) value of * the point `pos`. */ -void Turtle::setdir(const Point& pos) { +void Turtle::setdir(const Point &pos) +{ dir_ = pos.normalize(1); } @@ -118,12 +181,14 @@ void Turtle::setdir(const Point& pos) { * The direction is set to the (normalized) value of * the point `(x,y)`. */ -void Turtle::setdir(const float x, const float y) { +void Turtle::setdir(const float x, const float y) +{ setdir(Point(x, y)); } /** Turns the Turle `degreesccw` degrees. */ -void Turtle::turn(const float degreesccw) { +void Turtle::turn(const float degreesccw) +{ float radcw = -degreesccw / 180.0 * 3.141592653589; dir_ = Point(cos(radcw) * dir_.x_ - sin(radcw) * dir_.y_, sin(radcw) * dir_.x_ + cos(radcw) * dir_.y_); @@ -132,14 +197,16 @@ void Turtle::turn(const float degreesccw) { /** Turns the turtle right `degreesccw`. * This is a convenience alias for `turn`. */ -void Turtle::right(float degreesccw) { +void Turtle::right(float degreesccw) +{ turn(degreesccw); } /** Turns the turtle left `degreesccw`. * This is a convenience alias for `turn(-degreesccw)`. */ -void Turtle::left(float degreesccw) { +void Turtle::left(float degreesccw) +{ turn(-degreesccw); } @@ -149,7 +216,8 @@ void Turtle::left(float degreesccw) { * Moves the Turtle to its current location + `delta`, * using the Turtle's current move settings. */ -void Turtle::move(const Point& delta) { +void Turtle::move(const Point &delta) +{ gotopoint(position_ + delta); } @@ -160,7 +228,8 @@ void Turtle::move(const Point& delta) { * only argument. */ -void Turtle::move(const float x, const float y) { +void Turtle::move(const float x, const float y) +{ move(Point(x, y)); } @@ -168,7 +237,8 @@ void Turtle::move(const float x, const float y) { * Moves the Turtle to the point `(x, y)` using the Turtle's * current move settings. */ -void Turtle::gotopoint(const float x, const float y) { +void Turtle::gotopoint(const float x, const float y) +{ gotopoint(Point(x, y)); } @@ -176,17 +246,54 @@ void Turtle::gotopoint(const float x, const float y) { * Moves the Turtle to the point `(pos)` using the Turtle's * current move settings. */ -void Turtle::gotopoint(const Point& pos) { +void Turtle::gotopoint(const Point &pos) +{ // if (pos == position_) { // return; //} - if (pen_is_down_) { - if (satin_is_on_) { + if (pen_is_down_) + { + if (satin_is_on_) + { satin_stitch_to(pos); - } else { - stitch_to(pos); } - } else { + else + { + if (decor_active_) + { + switch (decor_stitch_) + { + case 0: + arrow_stitch_to(pos); + break; + case 1: + zigzag_stitch_to(pos); + break; + case 2: + feather_stitch_to(pos); + break; + case 3: + blanket_stitch_to(pos); + break; + case 4: + leafVine_stitch_to(pos); + break; + case 5: + squareZag_stitch_to(pos); + break; + case 6: + lightning_stitch_to(pos); + break; + } + } + else + { + stitch_to(pos); + } + } + } + else + { jump_to(pos); } } @@ -195,7 +302,8 @@ void Turtle::gotopoint(const Point& pos) { * Moves the turtle `dist` in the direction it * is currently facing. */ -void Turtle::forward(const float dist) { +void Turtle::forward(const float dist) +{ move(dir_ * dist); } @@ -203,7 +311,8 @@ void Turtle::forward(const float dist) { * Moves the turtle `-dist` in the direction it * is currently facing. */ -void Turtle::backward(const float dist) { +void Turtle::backward(const float dist) +{ move(dir_ * dist * -1); } @@ -216,11 +325,13 @@ void Turtle::backward(const float dist) { * Scale determines the size of the letters that are drawn. */ -bool notInAlphabet(char c) { +bool notInAlphabet(char c) +{ return Alphabet.find(c) == Alphabet.end(); } -void Turtle::displayMessage(string message, float scale) { +void Turtle::displayMessage(string message, float scale) +{ transform(message.begin(), message.end(), message.begin(), ::toupper); message.erase(remove_if(message.begin(), message.end(), notInAlphabet), message.end()); @@ -229,15 +340,17 @@ void Turtle::displayMessage(string message, float scale) { float start_y = position_.y_; float max_x = position_.x_; - for (char& nextChar : message) { + for (char &nextChar : message) + { penup(); - for (const Point& p : Alphabet[nextChar]) { + for (const Point &p : Alphabet[nextChar]) + { move(p * scale); if (position_.x_ > max_x) max_x = position_.x_; pen_is_down_ = pen_was_down; } - penup(); // raise pen to jump to next letter + penup(); // raise pen to jump to next letter gotopoint(max_x + 3 * scale, start_y); pen_is_down_ = pen_was_down; } @@ -248,7 +361,8 @@ void Turtle::displayMessage(string message, float scale) { /** Print a Turtle object. * Useful for debugging. */ -std::ostream& operator<<(std::ostream& os, const Turtle& t) { +std::ostream &operator<<(std::ostream &os, const Turtle &t) +{ os << "Turtle(position=" << t.position_ << ",Direction=" << t.dir_ << ")"; return os; } @@ -257,7 +371,8 @@ std::ostream& operator<<(std::ostream& os, const Turtle& t) { * This is very important -- without it, the embroidery machine * doesn't read the file correctly. */ -void Turtle::end() { +void Turtle::end() +{ embPattern_addStitchRel(emb_, 0, 0, END, color_); } @@ -266,12 +381,16 @@ void Turtle::end() { * The extension on `fname` determines the embroidery format that is used. * For CS70, we will always use the `.dst` extension. */ -void Turtle::save(std::string fname) { - if (density_error_) { +void Turtle::save(std::string fname) +{ + if (density_error_) + { cerr << "Not writing output file because density errors occurred:" << endl; - for (const auto& entry : density_) { - if (entry.second > DENSITY_ERROR_LIMIT) { + for (const auto &entry : density_) + { + if (entry.second > DENSITY_ERROR_LIMIT) + { cerr << " " << entry.second << " stitches at " << entry.first << endl; } @@ -279,11 +398,14 @@ void Turtle::save(std::string fname) { return; } - if (density_warning_) { + if (density_warning_) + { cerr << "Use caution with output file; density warnings occurred:" << endl; - for (const auto& entry : density_) { - if (entry.second > DENSITY_WARN_LIMIT) { + for (const auto &entry : density_) + { + if (entry.second > DENSITY_WARN_LIMIT) + { cerr << " * " << entry.second << " stitches at " << entry.first << endl; } @@ -294,50 +416,235 @@ void Turtle::save(std::string fname) { // Lower-level functions, set to private -void Turtle::stitch(const Point& pos) { +void Turtle::stitch(const Point &pos) +{ embPattern_addStitchRel(emb_, pos.x_, pos.y_, 0, color_); check_density(position_ + pos); position_ += pos; } -void Turtle::stitch_abs(const Point& pos) { +void Turtle::stitch_abs(const Point &pos) +{ embPattern_addStitchAbs(emb_, pos.x_, pos.y_, 0, color_); check_density(pos); position_ = pos; } -void Turtle::jump_to(const Point& pos) { +void Turtle::jump_to(const Point &pos) +{ embPattern_addStitchAbs(emb_, pos.x_, pos.y_, JUMP, color_); // check_density(pos); position_ = pos; } -void Turtle::stitch_to(const Point& pos) { +void Turtle::stitch_to(const Point &pos) +{ float total_length = (position_ - pos).length(); size_t num_stitches = abs(int(total_length / stepsize_)); Point step = (pos - position_) / num_stitches; - for (size_t i = 0; i < num_stitches; ++i) { + for (size_t i = 0; i < num_stitches; ++i) + { stitch(step); } stitch_abs(pos); } +void Turtle::arrow_stitch_to(const Point &pos) +{ + float total_length = (position_ - pos).length(); + size_t num_stitches = abs(int(total_length / stepsize_)); + + // Point step = (pos - position_) / num_stitches; + // Point end = position_; + for (size_t i = 0; i < num_stitches; ++i) + { + + stitch(dir_ * stepsize_); // first stitch, straight line + // right diagonal + right(45); // turn right + stitch(dir_ * stepsize_ / 2); // stitch forward, half a step in the turned direction + stitch(dir_ * -1 * stepsize_ / 2); // stitch backward + left(45); // reset orientation forward + + // left diagonal + left(45); // turn left + stitch(dir_ * stepsize_ / 2); // stitch forward, half a step in the turned direction + stitch(dir_ * -1 * stepsize_ / 2); // backward + right(45); // reset orientation forward + } + stitch_abs(pos); +} + +void Turtle::zigzag_stitch_to(const Point &pos) +{ + float total_length = (position_ - pos).length(); + size_t num_stitches = abs(int(total_length / stepsize_ / sqrt(2))); + + // Point step = (pos - position_) / num_stitches; + // Point end = position_; + + right(45); + for (size_t i = 0; i < num_stitches; ++i) + { + stitch(dir_ * stepsize_); // first stitch, straight line + left(90); + stitch(dir_ * stepsize_); + right(90); + } + left(45); + stitch_abs(pos); +} + +void Turtle::feather_stitch_to(const Point &pos) +{ + float total_length = (position_ - pos).length(); + size_t num_stitches = abs(int(total_length / stepsize_ / .35)) - 1; + bool go_left = true; + + right(45); + stitch(dir_ * stepsize_ / 2); // first stitch, straight line + for (size_t i = 0; i < num_stitches; ++i) + { + stitch(dir_ * stepsize_ / 2 * -1); // first stitch, straight line + + if (go_left) + { + left(90); + } + else + { + right(90); + } + stitch(dir_ * stepsize_); + go_left = !go_left; + } + stitch(dir_ * stepsize_ * -1); + + if (go_left) + { + left(45); + } + else + { + right(45); + } + + stitch_abs(pos); +} + +void Turtle::blanket_stitch_to(const Point &pos) +{ + float total_length = (position_ - pos).length(); + size_t num_stitches = abs(int(total_length / stepsize_)); + + // Point step = (pos - position_) / num_stitches; + // Point end = position_; + for (size_t i = 0; i < num_stitches; ++i) + { + stitch(dir_ * stepsize_); // first stitch, straight line + // right diagonal + right(90); // turn right + stitch(dir_ * stepsize_ / 2); // stitch forward, half a step in the turned direction + stitch(dir_ * -1 * stepsize_ / 2); // stitch backward + left(90); + } + stitch_abs(pos); +} + +void Turtle::leafVine_stitch_to(const Point &pos) +{ + float total_length = (position_ - pos).length(); + size_t num_stitches = abs(int(total_length / stepsize_)); + bool go_left = true; + + for (size_t i = 0; i < num_stitches; ++i) + { + stitch(dir_ * stepsize_); // first stitch, straight line + if (go_left) + { + // right diagonal + left(45); // turn right + stitch(dir_ * stepsize_ / 2); // stitch forward, half a step in the turned direction + right(45); + stitch(dir_ * stepsize_ / 2); + right(135); + stitch(dir_ * stepsize_ / 2); + right(45); + stitch(dir_ * stepsize_ / 2); + left(180); + } + else + { + // right diagonal + right(45); // turn right + stitch(dir_ * stepsize_ / 2); // stitch forward, half a step in the turned direction + left(45); + stitch(dir_ * stepsize_ / 2); + left(135); + stitch(dir_ * stepsize_ / 2); + left(45); + stitch(dir_ * stepsize_ / 2); + right(180); + } + go_left = !go_left; + } + stitch_abs(pos); +} + +void Turtle::squareZag_stitch_to(const Point &pos) +{ + float total_length = (position_ - pos).length(); + size_t num_stitches = abs(int(total_length / stepsize_)); + + for (size_t i = 0; i < num_stitches; ++i) + { + stitch(dir_ * stepsize_ / 2); + left(90); + stitch(dir_ * stepsize_ / 2); + right(90); + stitch(dir_ * stepsize_ / 2); + right(90); + stitch(dir_ * stepsize_ / 2); + left(90); + } + stitch_abs(pos); +} -void Turtle::satin_stitch_to(const Point& pos) { +void Turtle::lightning_stitch_to(const Point &pos) +{ + float total_length = (position_ - pos).length(); + size_t num_stitches = abs(int(total_length / stepsize_ / 2)); + + for (size_t i = 0; i < num_stitches; ++i) + { + left(30); + stitch(dir_ * (stepsize_ * 1.73)); + right(90); + stitch(dir_ * stepsize_); + left(60); + } + + stitch_abs(pos); +} + +void Turtle::satin_stitch_to(const Point &pos) +{ float total_length = (position_ - pos).length(); size_t num_stitches = abs(int(total_length / satin_delta_)); Point step = (pos - position_) / num_stitches; Point old_dir = dir_; - if (num_stitches > 0) { + if (num_stitches > 0) + { turntoward(pos); left(90); stitch(dir_ * -stepsize_ / 2); } - for (size_t i = 0; i < num_stitches; ++i) { + for (size_t i = 0; i < num_stitches; ++i) + { stitch(dir_ * stepsize_); stitch(step + dir_ * -stepsize_); } @@ -346,14 +653,18 @@ void Turtle::satin_stitch_to(const Point& pos) { dir_ = old_dir; } -void Turtle::check_density(const Point& pos) { +void Turtle::check_density(const Point &pos) +{ string key = pos.tostr(DENSITY_PRECISION); auto entry = density_.find(key); - if (entry == density_.end()) { + if (entry == density_.end()) + { density_[key] = 1; entry = density_.find(key); - } else { + } + else + { entry->second++; } density_warning_ |= (entry->second > DENSITY_WARN_LIMIT); diff --git a/src/turtle.hpp b/src/turtle.hpp index 5276152..aa3d09f 100644 --- a/src/turtle.hpp +++ b/src/turtle.hpp @@ -6,73 +6,86 @@ #include "point.hpp" #include -class Turtle { - public: - Turtle(); - ~Turtle(); +class Turtle +{ +public: + Turtle(); + ~Turtle(); - void setStepSize(float step); - void satinon(float delta); - void satinoff(); - void pendown(); - void penup(); - Point position(); + void setStepSize(float step); + void satinon(float delta); + void satinoff(); + void set_decor_stitch(int index); + void decor_on(int index); + void decor_off(); + void pendown(); + void penup(); + Point position(); - void turntoward(const Point& pos); - void turntoward(const float x, const float y); - void setdir(const Point& pos); - void setdir(const float x, const float y); - void turn(const float degreesccw); - void right(float degreesccw); - void left(float degreesccw); + void turntoward(const Point &pos); + void turntoward(const float x, const float y); + void setdir(const Point &pos); + void setdir(const float x, const float y); + void turn(const float degreesccw); + void right(float degreesccw); + void left(float degreesccw); - void move(const Point& delta); - void move(const float x, const float y); - void gotopoint(const Point& pos); - void gotopoint(const float x, const float y); - void forward(const float dist); - void backward(const float dist); + void move(const Point &delta); + void move(const float x, const float y); + void gotopoint(const Point &pos); + void gotopoint(const float x, const float y); + void forward(const float dist); + void backward(const float dist); - void displayMessage(std::string message, float scale); + void displayMessage(std::string message, float scale); - void save(std::string fname); - void end(); + void save(std::string fname); + void end(); - friend std::ostream& operator<<(std::ostream& os, const Turtle& t); + friend std::ostream &operator<<(std::ostream &os, const Turtle &t); - private: - void stitch(const Point& pos); - void stitch_abs(const Point& pos); - void jump_to(const Point& pos); - void stitch_to(const Point& pos); - void satin_stitch_to(const Point& pos); - void check_density(const Point& pos); - void set_x(const float x); - void set_y(const float y); - void increment_x(const float x); - void increment_y(const float y); - // void rectangle(float w, float h); - // void circle(float radius); - // void snowflake(float sidelength, int levels); - // void flakeside(float sidelength, int levels); - // void squareSpiral(int line); - // void tree(int branch); - // void svtree(float trunklength, int levels, float trunkwidth); - private: - static const int DENSITY_PRECISION = 0; - static const int DENSITY_WARN_LIMIT = 15; - static const int DENSITY_ERROR_LIMIT = 20; - EmbPattern* emb_; - float stepsize_; - int color_; - bool pen_is_down_; - bool satin_is_on_; - float satin_delta_; - Point dir_; - Point position_; - std::map density_; - bool density_error_; - bool density_warning_; +private: + void stitch(const Point &pos); + void stitch_abs(const Point &pos); + void jump_to(const Point &pos); + void stitch_to(const Point &pos); + void arrow_stitch_to(const Point &pos); + void zigzag_stitch_to(const Point &pos); + void feather_stitch_to(const Point &pos); + void blanket_stitch_to(const Point &pos); + void leafVine_stitch_to(const Point &pos); + void squareZag_stitch_to(const Point &pos); + void lightning_stitch_to(const Point &pos); + void satin_stitch_to(const Point &pos); + void check_density(const Point &pos); + void set_x(const float x); + void set_y(const float y); + void increment_x(const float x); + void increment_y(const float y); + // void rectangle(float w, float h); + // void circle(float radius); + // void snowflake(float sidelength, int levels); + // void flakeside(float sidelength, int levels); + // void squareSpiral(int line); + // void tree(int branch); + // void svtree(float trunklength, int levels, float trunkwidth); +private: + static const int DENSITY_PRECISION = 0; + static const int DENSITY_WARN_LIMIT = 15; + static const int DENSITY_ERROR_LIMIT = 20; + EmbPattern *emb_; + float stepsize_; + int color_; + bool pen_is_down_; + bool satin_is_on_; + float satin_delta_; + int decor_stitch_; + bool decor_active_; + Point dir_; + Point position_; + std::map density_; + bool density_error_; + bool density_warning_; }; #endif