{"id":16708447,"url":"https://github.com/milmazz/turtle","last_synced_at":"2025-04-10T05:22:33.962Z","repository":{"id":44012617,"uuid":"209294014","full_name":"milmazz/turtle","owner":"milmazz","description":"Turtle Graphics using Elixir","archived":false,"fork":false,"pushed_at":"2023-12-18T20:23:46.000Z","size":965,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T08:33:16.748Z","etag":null,"topics":["draw","elixir","turtle-graphics"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/milmazz.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}},"created_at":"2019-09-18T11:41:39.000Z","updated_at":"2024-03-22T13:52:38.000Z","dependencies_parsed_at":"2022-09-06T14:22:23.345Z","dependency_job_id":null,"html_url":"https://github.com/milmazz/turtle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milmazz%2Fturtle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milmazz%2Fturtle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milmazz%2Fturtle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milmazz%2Fturtle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/milmazz","download_url":"https://codeload.github.com/milmazz/turtle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239157253,"owners_count":19591292,"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":["draw","elixir","turtle-graphics"],"created_at":"2024-10-12T19:44:47.344Z","updated_at":"2025-02-16T16:31:54.097Z","avatar_url":"https://github.com/milmazz.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Turtle\n\nTurtle Graphics is a popular way to teach programming, particularly for kids. It\nwas initially part of the Logo programming language, created by Wally Feurzing\nand Seymour Papert in 1966. Imagine a robotic turtle that starts in `{0,0}` on\nthe cartesian plane. After importing the `Turtle` module, you would be able to\nuse `IEx` (the interactive shell for Elixir) to send commands like `forward(15)`\nand get the turtle to advance 15 pixels forward, drawing a line while moving.\nYou can draw pretty complex figures and\npictures by combining that with other commands.\n\nThis repository includes an experimental Elixir implementation about the\nprevious ideas, it should allow users to do all that using the Scenic\nframework.\n\n## How to run the examples\n\n```console\n$ cd turtle_ui\n$ iex -S mix\n```\n\nAnd then, inside IEx you can do:\n\n```elixir\niex(1)\u003e c \"examples/tree.ex\"\niex(2)\u003e TurtleUI.pen_down()\n:ok\niex(3)\u003e TurtleUI.Examples.Tree.example()\n:ok\n```\n\nSee the result on Scenic. If you want to run another example, you first need to\nclean your view and then execute the next example like this:\n\n```elixir\niex(4)\u003e c \"examples/sierpinski_triangle.ex\"\niex(5)\u003e TurtleUI.reset()\n:ok\niex(6)\u003e TurtleUI.Examples.SierpinskiTriangle.example()\n:ok\n```\n\nYou can also opt to compile all the examples at once by doing something like:\n\n```elixir\niex(7)\u003e for file \u003c- Path.wildcard(\"examples/*.ex\"), do: Code.compile_file(file)\n```\n\nIn the directory `turtle_ui/examples` you can find more examples, here I show you some of them:\n\n![flower](./turtle_ui/examples/flower.png)\n\n![triangle](./turtle_ui/examples/sierpinski_triangle.png)\n\n![spiral](./turtle_ui/examples/spiral.png)\n\n![star](./turtle_ui/examples/star.png)\n\n## TODO\n\n### Turtle Motion\n\n#### Move \u0026 Draw\n\n* [x] `forward/1` (alias: `fd/1`) - Move the turtle forward by the specified distance.\n* [x] `backward/1` (aliases: `bk/1`, `back/1`) - Move the turtle backward by given distance.\n* [x] `right/1` (alias: `rt/1`) - Turn turtle right by _angle_ units (_degress_ by default).\n* [x] `left/1` (alias: `lt/1`) - Turn turtle left by _angle_ units (_degress_ by default).\n* [x] `go_to/1` - Move turtle to an absolute position.\n* [x] `go_to/2` - Move turtle to an absolute position.\n* [x] `set_x` - Set the turtle's x coordinate.\n* [x] `set_y` - Set the turtle's y coordinate.\n* [x] `set_heading` - Set the turtle's orientation to _angle_.\n* [x] `home` - Move turtle to origin coordinates (0, 0) and set its heading to its start orientation.\n* [ ] `circle` - Draw a circle with given radius.\n* [ ] `dot` - Draw a circular dot with diameter size, using color.\n* [x] `undo/0` - Undo the last turtle action(s).\n* [ ] `speed` - Set the turtle's speed to an integer value in the range `0..10`, also allow to use _atoms_ like:\n  - `:fastest`\n  - `:fast`\n  - `:normal`\n  - `:slow`\n  - `:slowest`\n\n#### Turtle's state\n\n* [x] `position/0` - Return the turtle's current location\n* [x] `towards/1` - Return the angle between the line from turtle position to position specified by (x, y)\n* [x] `towards/2`\n* [x] `x_cor/0` - Return the turtle’s x coordinate.\n* [x] `y_cor/0` - Return the turtle’s y coordinate.\n* [x] `heading/0` - Return the turtle’s current heading\n* [x] `distance/1` and `distance/2` - Return the distance from the turtle to (x, y)\n\n#### Setting and measurement\n\n* [ ] `degress` - Set angle measurement units, i.e. set number of “degrees” for\n  a full circle. Default value is 360 degrees.\n* [ ] `radians` - Set the angle measurement units to radians. Equivalent to `degrees(2*math.pi)`.\n\n### Pen control\n\n#### Drawing state\n\n* [x] `pen_down/0` - Pull the pen down - drawing when moving.\n* [x] `pen_up/0` - Pull the pen up - no drawing when moving.\n* [x] `pen_size/0` - Return the line thickness.\n* [x] `pen_size/1` - Set the line thickness.\n* [x] `pen_down?/0` - Return `true` if pen is down, `false` if it's up.\n\n#### Color control\n\n* [x] `pen_color/0` - Return the pen color\n* [x] `pen_color/1` - Set the pen color\n* [ ] `fill_color/0` - Return the fill color\n* [ ] `fill_color/1` - Set the fill color\n\n#### Filling\n\n* [ ] `fill/0` - Return `fill` state (`true` if filling).\n* [ ] `fill/1` - Call `fill(true)` before drawing the shape you want to fill, and `fill(false)` when done.\n* [ ] `begin_fill/0` - same as `fill(true)`\n* [ ] `end_fill/0` - same as `fill(false)`\n\n#### More drawing control\n\n* [x] `reset` - delete the turtle's drawings from screen, re-center the turtle\n      and set the variables to the default values\n* [x] `clear` - delete the turtle’s drawings from the screen. Do not move\n      turtle. State and position of the turtle as well as drawings of other\n      turtles are not affected.\n\n### Other improvements\n\n* [ ] Add support `mode` (standard, logo)?\n* [ ] Update arrow at the end of each movement\n* [ ] Move functionality from `Home` scene into it own `turtle` Scenic Component?\n* [ ] Support more than one Turtle, allow to set a cluster of turtles and share the state among them :)\n* [ ] Improve README\n* [ ] Improve examples. See this [issue](https://github.com/sunjay/turtle/issues/25) as a reference\n* [ ] Add more doctest, more unit tests, property testing?\n* [ ] Add a CHANGELOG https://keepachangelog.com/en/1.0.0/\n\n## References\n\n* https://docs.python.org/2/library/turtle.html#turtle.write\n* https://github.com/sunjay/turtle\n* https://cs.brown.edu/courses/bridge/1997/Resources/LogoTutorial.html\n* http://www.logointerpreter.com/logo-reference/\n* https://github.com/boydm/scenic\n* https://en.m.wikipedia.org/wiki/Flood_fill\n* https://github.com/buckle2000/turtle-playback/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilmazz%2Fturtle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilmazz%2Fturtle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilmazz%2Fturtle/lists"}