{"id":28952176,"url":"https://github.com/vrmiguel/taruga","last_synced_at":"2025-06-23T16:14:22.082Z","repository":{"id":129412184,"uuid":"303055137","full_name":"vrmiguel/taruga","owner":"vrmiguel","description":"Taruga is a work in progress single-header turtle graphics library written in C++11","archived":false,"fork":false,"pushed_at":"2025-06-12T21:33:48.000Z","size":1631,"stargazers_count":20,"open_issues_count":4,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-12T22:39:49.630Z","etag":null,"topics":["cpp","sfml","turtle"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vrmiguel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-10-11T06:16:04.000Z","updated_at":"2025-06-12T21:21:46.000Z","dependencies_parsed_at":"2023-04-09T03:01:04.104Z","dependency_job_id":null,"html_url":"https://github.com/vrmiguel/taruga","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vrmiguel/taruga","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrmiguel%2Ftaruga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrmiguel%2Ftaruga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrmiguel%2Ftaruga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrmiguel%2Ftaruga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vrmiguel","download_url":"https://codeload.github.com/vrmiguel/taruga/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrmiguel%2Ftaruga/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261510085,"owners_count":23169691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","sfml","turtle"],"created_at":"2025-06-23T16:14:19.187Z","updated_at":"2025-06-23T16:14:22.034Z","avatar_url":"https://github.com/vrmiguel.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# taruga [![Codacy Badge](https://app.codacy.com/project/badge/Grade/438ef0f9e2bc4a579e816f186f0a2385)](https://www.codacy.com/gh/vrmiguel/taruga/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=vrmiguel/taruga\u0026amp;utm_campaign=Badge_Grade) [![CodeFactor](https://www.codefactor.io/repository/github/vrmiguel/taruga/badge)](https://www.codefactor.io/repository/github/vrmiguel/taruga)\n\nTaruga is a work in progress single-header turtle graphics library written in C++11.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/36349314/95826050-236a4a80-0d08-11eb-8032-a8644704e423.gif\" alt=\"Spiral\"/\u003e\n\u003c/p\u003e\n\n## Examples\n\n### Drawing a Sierpinski fractal\n\n![Sierpinski](https://user-images.githubusercontent.com/36349314/95699821-e2950780-0c1b-11eb-8fa9-15b2e913ecc5.png)\n\nWith the simple Turtle directives, we can build complex fractals!\n\nFull source code for this example can be found [here](examples/spiral.cpp).\n\n### Drawing a spiral \n\n![Spiral](https://user-images.githubusercontent.com/36349314/95693453-c6d13780-0c02-11eb-9d4e-5d3b3467899e.png)\n\nWe can draw this spiral by simply moving forward and then turning to the right by slightly over 90°.\n\n```cpp\n    int size = 1;\n    while (size \u003c= 500)\n    {\n        turtle.forward(size++);\n        turtle.turn_right(91);\n    }\n```\n\nFull source code for this example  can be found [here](examples/spiral.cpp). \n\n### Using colors\n\n![Colors](https://user-images.githubusercontent.com/36349314/95693689-fdf41880-0c03-11eb-800d-30867ebc2dd1.png)\n\nWe can change around the color of the lines drawn by using `Turtle::set_line_color`, to which you can supply either an RGB triplet (by individual values or in an array) or a [sf::Color](https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Color.php).\n\n```cpp\n    std::vector\u003csf::Color\u003e colors = {sf::Color::Red, sf::Color::Blue, sf::Color::Green, sf::Color::Yellow};\n\n    for(auto color : colors)\n    {\n        turtle.set_line_color(color);\n        turtle.forward(70);\n        turtle.turn_left(90);\n    }\n```\n\nFull source code for this example can be found [here](examples/colored_square.cpp). \n\n### Lifting the pen up, drawing regular polygons\n\n![Regular polygons](https://user-images.githubusercontent.com/36349314/95693724-3136a780-0c04-11eb-8797-9a25fc45ef2d.png)\n\nWe can set the turtle's pen up or down. This allows us to move the turtle without having to draw the line of its path.\n\nFull source code for this example can be found [here](examples/regular_polygon.cpp). \n\n### Drawing a Koch fractal\n\n![Koch](https://user-images.githubusercontent.com/36349314/95706813-4f190200-0c2e-11eb-8cdb-6d1ad3d00b89.png)\n\nFull source code for this example can be found [here](examples/koch.cpp).\n\n## Dependencies and how to build\n\nThe only dependencies are a C++11 conformant compiler and [SMFL](https://www.sfml-dev.org/index.php), a small multimedia API with an installed size of around 10MB.\n\n\nTaruga has been built on SFML 2.5.1 and has also been tested on SFML 2.4.1. It may work on older versions of the library, but there are no guarantees.\n\nOn Ubuntu-based distributions, you can install SFML with:\n\n```sudo apt install libsfml-dev```\n\nOn Fedora, with:\n```dnf install SFML```\n\nYou can then build it ```g++ -O3 -std=c++11 your_program.cpp -lsfml-graphics -lsfml-window -lsfml-system```.\n\n## Usage\n\nTaruga exposes a single namespace, contained within a single header file ([`taruga.hpp`](include/taruga.hpp)).\nThe public methods that `taruga::Turtle` exposes are:\n\n```cpp\n    void set_window_title(const char* new_title);\n    Turtle();                          //! Default constructor. Makes a window size of 800x600 and sets the turtle to (400, 300).\n    Turtle(uint16_t width, uint16_t height); //! Makes a window size of width * height and sets the turtle (width/2, height/2).\n    explicit Turtle(const sf::Vector2f\u0026 p);  //! Makes a window size of p.x * p.y and sets the turtle (p.x/2, p.y/2).\n    void save_to_image(const char *);  //! Saves the current window view to an image with the given filename\n    void set_line_color(sf::Color);    //! Sets the new color of the line the turtle will draw.\n    void set_line_color(u8, u8, u8);   //! Sets the new color of the line the turtle will draw.\n    void set_line_color(u8[3]);        //! Sets the new color of the line the turtle will draw.\n    void pen_up();                     //! Sets the pen up so lines don't get drawn\n    void pen_down();                   //! Sets the pen down so that the turtle draws a line wherever it walks\n    void set_icon(Icon);               //! Allows to switch around between the two built-in icons: turtle or straight arrow.\n    void set_icon(sf::Texture);        //! Allows for any image to be used as an icon. Do notice that Taruga won't scale the texture. If needed, use the Turtle::scale method.\n    void scale(float, float);          //! Scales the turtle sprite\n    void forward(float units);         //! Walk forward the given amount of units.\n    void backwards(float units);       //! Walk backwards the given amount of units. The same as using forward() with a negative parameter.\n    void turn_right(float ang);        //! Turns right by the specified amount of degrees.\n    void set_walking_speed(float);     //! Sets a new walking speed\n    void set_rotation_speed(float);    //! Sets a new rotation speed\n    void push_state();                 //! Saves the current state in a stack\n    void pop_state();                  //! Returns the Turtle's state to the top of the state stack\n    void turn_left(float ang);         //! Turns left by the specified amount of degrees.\n    void act();                        //! Start moving the turtle. Will deplete the actions queue.\n```\n\n## Licensing\n\nThe code contained in this repo is [MIT](https://opensource.org/licenses/MIT)-licensed.\n\nTurtle icon made by Freepik, available under the [Flaticon](https://www.flaticon.com/) license. \n\nSFML is [zlib/libpng](https://opensource.org/licenses/Zlib)-licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvrmiguel%2Ftaruga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvrmiguel%2Ftaruga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvrmiguel%2Ftaruga/lists"}