{"id":22962327,"url":"https://github.com/zonble/turtlebuilder","last_synced_at":"2025-10-12T07:11:50.504Z","repository":{"id":63921283,"uuid":"196683069","full_name":"zonble/TurtleBuilder","owner":"zonble","description":"Turtle graphics library built on Swift function builders","archived":false,"fork":false,"pushed_at":"2023-04-15T23:34:16.000Z","size":174,"stargazers_count":46,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-24T04:48:07.649Z","etag":null,"topics":["functionbuilder","logo","swift","turtle-graphics"],"latest_commit_sha":null,"homepage":"https://zonble.github.io/TurtleBuilder/","language":"Swift","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/zonble.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":"2019-07-13T05:39:19.000Z","updated_at":"2024-11-05T13:32:58.000Z","dependencies_parsed_at":"2025-08-13T06:33:58.010Z","dependency_job_id":"d82c8738-cee7-4555-ad4b-e587db704e9e","html_url":"https://github.com/zonble/TurtleBuilder","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zonble/TurtleBuilder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonble%2FTurtleBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonble%2FTurtleBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonble%2FTurtleBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonble%2FTurtleBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zonble","download_url":"https://codeload.github.com/zonble/TurtleBuilder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonble%2FTurtleBuilder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010644,"owners_count":26084783,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["functionbuilder","logo","swift","turtle-graphics"],"created_at":"2024-12-14T19:16:33.647Z","updated_at":"2025-10-12T07:11:50.474Z","avatar_url":"https://github.com/zonble.png","language":"Swift","readme":"# TurtleBuilder\n\n[![Actions Status](https://github.com/zonble/TurtleBuilder/workflows/Build/badge.svg)](https://github.com/zonble/TurtleBuilder/actions)\n[![Build](https://travis-ci.org/zonble/TurtleBuilder.svg?branch=master)](https://travis-ci.org/zonble/TurtleBuilder)\n[![GitHub Release](https://img.shields.io/github/release/zonble/turtlebuilder.svg)]()\n![GitHub Top Language](https://img.shields.io/github/languages/top/zonble/turtlebuilder.svg)\n[![License](https://img.shields.io/github/license/zonble/turtlebuilder.svg)](https://github.com/zonble/turtlebuilder/blob/master/LICENSE)\n[![Twitter](https://img.shields.io/badge/Twitter-%40zonble-blue.svg)](https://twitter.com/zonble)\n\nTurtleBuilder is a [turtle graphics](https://en.wikipedia.org/wiki/Turtle_graphics) made on the top of Swift's function builder. It allows you to use a [Logo](https://en.wikipedia.org/wiki/Logo_(programming_language))-like syntax to create and draw lines in your Swift project.\n\n[![TurtleBuilder Example](http://img.youtube.com/vi/mPF4nlYp-1c/0.jpg)](http://www.youtube.com/watch?v=mPF4nlYp-1c)\n\n## Why?\n\nBecause it is fun!\n\n## Requirement\n\n- Xcode 11 or above\n- Swift 5.1 or above\n\n## Installation\n\nYou can install TurtleBuilder into your project via Swift Package Manager.\n\n## Usage\n\n### Build a Turtle\n\nYou can use a build block to build a turtle. For example:\n\n``` swift\nlet turtle = Turtle {\n        penDown()\n        loop(9) {\n            left(140)\n            forward(30)\n            left(-100)\n            forward(30)\n        }\n        penUp()\n}\n```\n\nThen you can get lines from the turtle, by calling `turtle.lines`. If you render it, it would look like\n\n![screenshot.png](https://raw.githubusercontent.com/zonble/TurtleBuilder/master/screenshot.png)\n\n### Commands\n\nTurtleBuilder provides following commands to let you control your turtle:\n\n- pass: The command does nothing.\n- center: Move the turtle to the center of the canvas.\n- resetHeading: Reset the direction of the turtle. The turtle is facing to the top by default.\n- setHeading: Set the direction of the turtle..\n- penUp: After the command is called, the turtle moves without drawing a line.\n- penDown: After the command is called, the turtle draw a line when it is moving.\n- left | lt: Turn the turtle to left with a given degree.\n- right | rt: Turn the turtle to right with a given degree.\n- forward | fd: Ask the turtle to move forward.\n- loop | repeat: Repeat running a set of commands.\n- setMacro: Set a set of commands as a macro with a given name.\n- playMacro: Play a macro. The macro needs to be set before.\n\n## Draw In Views\n\nTurtleBuilder provides two views where you can let the turtle to draw graphics. One is `TurtleView`, it renders the still lines with Quartz 2D, while another is `AnimatedTurtleView`, which creates animating layers using Core Animation.\n\nYou can use `AnimatedTurtleView` as following:\n\n\n``` swift\nlet turtleView = AnimatedTurtleView(frame: self.view.bounds) {\n    penDown()\n    loop(10) {\n        left(10)\n        forward(10)\n    }\n    penUp()\n}\n```\n\nThen call `turtleView.animate()` to start the animation.\n\n## Known Issues\n\nIf you use variables in the commands within the `loop` command, we only take the values once. For example, if you have code as following:\n\n``` swift\nloop(5) {\n   left(Int(arc4random() % 50))\n   forward(Int(arc4random() % 50))\n}\n```\n\nWe do not generate new randrom numbers in each run of the loop, and the values sent to the commands remain identical.\n\n\nPatches are welcome. Enjoy! 🐢\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonble%2Fturtlebuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzonble%2Fturtlebuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonble%2Fturtlebuilder/lists"}