{"id":13822949,"url":"https://github.com/Awalz/SwiftyDraw","last_synced_at":"2025-05-16T17:32:49.442Z","repository":{"id":46053244,"uuid":"74911913","full_name":"Awalz/SwiftyDraw","owner":"Awalz","description":"A simple, lightweight drawing framework written in Swift","archived":false,"fork":false,"pushed_at":"2022-10-31T10:51:54.000Z","size":463,"stargazers_count":336,"open_issues_count":18,"forks_count":65,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-07-18T14:39:53.703Z","etag":null,"topics":["drawing","swift"],"latest_commit_sha":null,"homepage":"","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/Awalz.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":"2016-11-27T20:20:09.000Z","updated_at":"2024-07-16T00:44:05.000Z","dependencies_parsed_at":"2022-08-12T12:40:27.759Z","dependency_job_id":null,"html_url":"https://github.com/Awalz/SwiftyDraw","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Awalz%2FSwiftyDraw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Awalz%2FSwiftyDraw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Awalz%2FSwiftyDraw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Awalz%2FSwiftyDraw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Awalz","download_url":"https://codeload.github.com/Awalz/SwiftyDraw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213893313,"owners_count":15653524,"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":["drawing","swift"],"created_at":"2024-08-04T08:02:26.145Z","updated_at":"2024-08-04T08:09:18.180Z","avatar_url":"https://github.com/Awalz.png","language":"Swift","readme":"\u003ch1 align=\"center\"\u003eSwiftyDraw\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/platform-iOS%209%2B-blue.svg?style=flat\" alt=\"Platform: iOS 9.1+\"/\u003e\n    \u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg src=\"https://img.shields.io/badge/language-swift%205-4BC51D.svg?style=flat\" alt=\"Language: Swift 5\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://cocoapods.org/pods/SwiftyDraw\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/v/SwiftyDraw.svg?style=flat\" alt=\"CocoaPods\" /\u003e\u003c/a\u003e\n    \u003cimg src=\"http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat\" alt=\"License: MIT\" /\u003e \u003cbr\u003e\u003cbr\u003e\n\u003c/p\u003e\n\n\n## Overview\n\nSwiftyDraw is a simple, light-weight drawing framework written in Swift. SwiftyDraw is built using Core Gaphics and is very easy to implement.\n\n## Requirements\n* iOS 9.1+\n* Swift 5.0\n\n## Installation\n\n### Cocoapods:\n\nSwiftyDraw is available through [CocoaPods](http://cocoapods.org). To install\nit, add the following line to your Podfile:\n\n```ruby\npod 'SwiftyDraw'\n```\n\n### Carthage\n\nSwiftyDraw is also available through [Carthage](https://github.com/Carthage/Carthage/blob/master/README.md). To install, add the following line to your Cartfile:\n\n```ruby\ngithub \"awalz/SwiftyDraw\" \"master\"\n```\n\n### Manual Installation:\n\nSimply copy the contents of the Source folder into your project.\n\n## Usage\n\nUsing SwiftyDraw is very simple:\n\n### Getting Started:\n\nCreate a SwiftyDrawView and add it to your ViewController:\n\n```swift\nlet drawView = SwiftyDrawView(frame: self.view.frame)\nself.view.addSubview(drawView)\n```\n\nBy default, the view will automatically respond to touch gestures and begin drawing. The default brush is `.default`, which has a **black** color.\n\nTo disable drawing, simply set the `isEnabled` property to `false`:\n\n```swift\ndrawView.isEnabled = false\n```\n\n## Brushes\n\nFor drawing, we use `Brush` to keep track of styles like `width`, `color`, etc.. We have multiple different default brushes, you can use as follows:\n\n```swift\ndrawView.brush = Brush.default\n```\n\nThe default brushed are:\n\n```swift\npublic static var `default`: Brush { get } // black, width 3\npublic static var thin     : Brush { get } // black, width 2\npublic static var medium   : Brush { get } // black, width 7\npublic static var thick    : Brush { get } // black, width 10\npublic static var marker   : Brush { get } // flat red-ish, width 10\npublic static var eraser   : Brush { get } // clear, width 8; uses CGBlendMode to erase things\n```\n\n### Adjusted Width Factor\n\n`SwiftyDrawView` supports drawing-angle-adjusted brushes. This effectively means, if the user (using an Pencil) draws with the tip of the pencil, the brush will reduce its width a little. If the user draws at a very low angle, with the side of the pencil, the brush will be a little thicker.\nYou can modify this behavior by setting `adjustedWidthFactor` of a brush. If you increase the number (to, say, `5`) the changes will increase. If you reduce the number to `0`, the width will not be adjusted at all.\nThe default value is `1` which causes a slight de-/increase in width.\n\nThis is an opt-in feature. That means, in `shouldBeginDrawingIn`, you need to call `drawingView.brush.adjustWidth(for: touch)`.\n\n## Further Customization:\n\nFor more customization, you can modify the different properties of a brush to fit your needs.\n\n### Line Color:\n\nThe color of a line stroke can be changed by adjusting the `color` property of a brush. SwiftyDraw accepts any `Color`:\n\n```swift\ndrawView.brush.color = Color(.red)\n```\n    \n\u003cp align=\"center\"\u003e\n  or\n\u003c/p\u003e\n\n```swift\ndrawView.brush.color = Color(UIColor(colorLiteralRed: 0.75, green: 0.50, blue: 0.88, alpha: 1.0))\n```\n\nWe have our own implementation of `UIColor` – `Color` – to be able to de-/encode it.\n\n### Line Width:\n\nThe width of a line stroke can be changed by adjusting the `width` property of a brush. SwiftyDraw accepts any positive `CGFloat`:\n\n```swift\ndrawView.brush.width = 5.0\n```\n\n### Line Opacity:\n\nThe opacity of a line stroke can be changed by adjusting the `lineOpacity` property. SwiftyDraw accepts any `CGFloat` between `0` and `1`:\n\n```swift\ndrawView.brush.opacity = 0.5\n```\n    \n## Editing\n\n### Clear All:\n\nIf you wish to clear the entire canvas, simply call the `clear` function:\n\n```swift\ndrawView.clear()\n``` \n\n### Drawing History:\n\n```swift\ndrawView.undo()\n``` \n\n...and redo:\n\n```swift\ndrawView.redo()\n``` \n\nTo en-/disable custom un- \u0026 redo buttons, you can use `.canUndo` and `.canRedo`.\n\n## Apple Pencil Integration\nApple Pencil can be used for drawing in a SwiftyDrawView, just like a finger.  \nSpecial features, however, regarding Apple Pencil 2 are only supported on iOS 12.1 and above versions.\n\n### Apple Pencil 2 Double Tap action\n#### Enable/ Disable pencil interaction\nApple Pencil interaction is enabled by default, but you can set `drawView.isPencilInteractive` to change that setting.\n#### Pencil Events\nWhen double tapping the pencil, SwiftyDraw will check the user preferences set in the system. If the preference is set to switch to eraser, SwiftyDraw will switch between normal and erasing mode; if set to last used tool, SwiftyDraw will switch between current and previous brush.\n\n## Delegate\n\nSwiftyDraw has delegate functions to notify you when a user is interacting with a SwiftDrawView. To access these delegate methods, have your View Controller conform to the `SwiftyDrawViewDelegate` protocol:\n\n```swift\nclass ViewController: UIViewController, SwiftyDrawViewDelegate\n```\n\n### Delegate methods\n\n```swift\nfunc swiftyDraw(shouldBeginDrawingIn drawingView: SwiftyDrawView, using touch: UITouch) -\u003e Bool\n\nfunc swiftyDraw(didBeginDrawingIn drawingView: SwiftyDrawView, using touch: UITouch)\n\nfunc swiftyDraw(isDrawingIn drawingView: SwiftyDrawView, using touch: UITouch)\n    \nfunc swiftyDraw(didFinishDrawingIn drawingView: SwiftyDrawView, using touch: UITouch)\n    \nfunc swiftyDraw(didCancelDrawingIn drawingView: SwiftyDrawView, using touch: UITouch)\n```\n\n---\n \n## Contribution\n\nThis project was built by [Awalz](https://github.com/Awalz) and is mostly maintained \u0026 improved by [LinusGeffarth](https://github.com/LinusGeffarth).\n\nIf you'd like to propose any enhancements, bug fixes, etc., feel free to create a pull request or an issue respectively.\n\n### Contact\n\nIf you have any questions, or just want to say *Hi!*, you can reach me via [Twitter](https://twitter.com/linusgeffarth), or [email](mailto:linus@geffarth.com).\n\n### LICENSE\n\nSwiftyDraw is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":["Swift"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAwalz%2FSwiftyDraw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAwalz%2FSwiftyDraw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAwalz%2FSwiftyDraw/lists"}