{"id":16482787,"url":"https://github.com/shaps80/inkkit","last_synced_at":"2025-04-09T11:10:29.541Z","repository":{"id":56915496,"uuid":"55845611","full_name":"shaps80/InkKit","owner":"shaps80","description":"Drawing and Geometry made easy on iOS - now in Swift 3.0","archived":false,"fork":false,"pushed_at":"2017-11-08T17:19:56.000Z","size":2786,"stargazers_count":374,"open_issues_count":0,"forks_count":23,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-02T03:27:57.056Z","etag":null,"topics":["draw","drawing-methods","geometry","graphics","grid","ios"],"latest_commit_sha":null,"homepage":"http://shaps.me/blog/inkkit/","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/shaps80.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-04-09T13:26:48.000Z","updated_at":"2025-03-09T14:59:44.000Z","dependencies_parsed_at":"2022-08-21T03:50:36.421Z","dependency_job_id":null,"html_url":"https://github.com/shaps80/InkKit","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FInkKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FInkKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FInkKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FInkKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaps80","download_url":"https://codeload.github.com/shaps80/InkKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027407,"owners_count":21035594,"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","drawing-methods","geometry","graphics","grid","ios"],"created_at":"2024-10-11T13:12:01.950Z","updated_at":"2025-04-09T11:10:29.500Z","avatar_url":"https://github.com/shaps80.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# InkKit\n\n[![Version](https://img.shields.io/cocoapods/v/InkKit.svg?style=flat)](http://cocoapods.org/pods/InkKit)\n[![License](https://img.shields.io/cocoapods/l/InkKit.svg?style=flat)](http://cocoapods.org/pods/InkKit)\n[![Language](https://img.shields.io/badge/language-swift-ff69b4.svg)](http://cocoadocs.org/docsets/InkKit)\n[![Platform](https://img.shields.io/cocoapods/p/InkKit.svg?style=flat)](http://cocoapods.org/pods/InkKit)\n\n## Swift Support\n\n**Swift 4.0**\n\nInkKit is Swift 4.0 by default, so to use that just include InkKit in your podfile:\n\npod 'InkKit'\n\n**Swift 3.2**\n\nIn order to use InkKit in a Swift 3.2/3.0 project, ensure you point to the `2.1.0` tag.\n\n`pod 'InkKit', '2.1.0'`\n\n**Swift 2.3**\n\nIn order to use InkKit in a Swift 2.3 project, ensure you point to the `swift2.3` branch.\n\n`pod 'InkKit', :git =\u003e 'https://github.com/shaps80/InkKit/', :branch =\u003e 'swift2.3'`\n\n**Swift 2.2**\n\nIf you still require Swift 2.2, point your version as such:\n`pod 'InkKit', '1.3.1'`\n\n## Example Code\n\nEverything you see here, was code-drawn with InkKit! In fact, other than some `CGRect` instances, this is ALL the code required to draw the image you see on the right ;)\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth width=\"30%\"\u003eDrawing made simple!\u003c/th\u003e\n    \u003cth width=\"30%\"\u003eInkKit In Action\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eLets draw the screen on the right.\u003c/td\u003e\n    \u003cth rowspan=\"9\"\u003e\u003cimg src=\"https://camo.githubusercontent.com/3b91556602d4501e9916903939f35d1ea85697a7/687474703a2f2f73686170732e6d652f6173736574732f696d672f626c6f672f496e6b4b69742e676966\"\u003e\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\u003ctd\u003e\u003cdiv class=\"highlight highlight-source-swift\"\u003e\u003cpre\u003e\nDraw.fillRect(bgFrame, color: UIColor(hex: \"1c3d64\"))\nlet grid = Grid(colCount: 6, rowCount: 9, bounds: gridFrame)\nlet path = grid.path(includeComponents: [.Columns, .Rows])\n\nDraw.strokePath(path, startColor: UIColor(white: 1, alpha: 0.15),\n    endColor: UIColor(white: 1, alpha: 0.05), angleInDegrees: 90)\n\nlet rect = grid.boundsForRange(sourceColumn: 1, sourceRow: 1,\n                      destinationColumn: 4, destinationRow: 6)\n\ndrawCell(rect, title: \"4x6\",\n  includeBorder: true, includeShadow: true)\n\nDraw.addShadow(.Outer, path: UIBezierPath(rect: barFrame),\n           color: UIColor(white: 0, alpha: 0.4), radius: 5,\n                       offset: CGSize(width: 0, height: 1))\n\nDraw.fillRect(barFrame, color: UIColor(hex: \"ff0083\"))\n\nlet (_, navFrame) = barFrame.divide(20, fromEdge: .MinYEdge)\n\"InkKit\".drawAlignedTo(navFrame, attributes: [\n  NSForegroundColorAttributeName: Color.whiteColor(),\n  NSFontAttributeName: UIFont(name: \"Avenir-Book\", size: 20)!\n])\n\nbackIndicatorImage().drawAtPoint(CGPoint(x: 22, y: 30))  \n\u003c/pre\u003e\u003c/div\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e\n\n## Change Log\n\n**v2.0.0**\n\nNote: Since this is a Swift 3 release, I decided to also clean up the API and remove all deprecation warnings. InkKit 2.0 should be considered a new API.\n\n* Swift 3.0 Support\n* Updated API to support Swift 3.0 guidelines\n* Shear Transforms\n* Perspective Transforms\n* Radians from Degrees function (and inverse)\n* Corner Radius with Concave, Convex and Line support\n* New Color value-type\n\n\n**v1.3.1**\n\n* OSX Support\n* OSX Demo Project now included\n* ~~Table~~ renamed to Grid\n* ~~Table~~ renamed to GridComponents\n* Added convenience methods for working with paths\n\n**v1.2.0**\n\n* Shadows\n* Borders\n* Tables\n\n**v1.1.0**\n\n* Images\n* Strings\n\n**v1.0**\n\n* Fills\n* Strokes\n* Geometry\n\n## API\n\nInkKit provides many useful convenience methods for drawing and geometry calculations. Its also cross platform working across iOS \u0026 MacOS\n\n### Core\n\nIf the convenience methods below don't solve your needs, you can start by using the new methods added directly to `CGContext` itself:\n\n```swift\nfunc draw(inRect:attributes:drawing:)\n```\n\nWhich would look like this in usage:\n\n```swift\nCGContext.current?.draw(inRect: rect, drawing: { (context, rect, attributes) in\n  Color.redColor.setFill()\n  UIRectFill(rect)\n})\n```\n\nThis basically wraps getting the context, setting up its frame and save/restore calls. If you provide the additional DrawingAttributes block, it will also pre-configure your context with those options for you.\n\n### Grid\n\n```swift\ninit(colCount:rowCount:bounds:)\nfunc positionForCell(atIndex:) -\u003e (col: Int, row: Int)\nfunc boundsForCell(atIndex:) -\u003e CGRect\nfunc boundsForRange(sourceColumn:sourceRow:destinationColumn:destinationRow:) -\u003e CGRect\nfunc boundsForCell(col:row:) -\u003e CGRect\nfunc enumerateCells(enumerator:(index:col:row:bounds:) -\u003e Void)\n```\n\nA `Grid` is a really great way for laying out your drawing without having to think about placement, rect translations, etc...\n\nI use them often for layout only, but sometimes its useful to be able to render them as well (like in the included demo).\n\n```swift\n// components is a bitmask [ .Outline, .Rows, .Columns ]\nfunc stroke(components:attributes:)\n```\n\n### Borders \u0026 Shadows\n\nSupports `.Outer`, `.Inner` and `.Center` borders, as well as `.Outer` and `.Inner` shadows.\n\n```swift\nstatic func addBorder(type:path:attributes:)\nstatic func addShadow(type:path:color:radius:offset:)\n```\n\n### Strokes\n\n```swift\nstatic func strokeLine(startPoint:endPoint:startColor:endColor:angleInDegrees:attributes:)\nstatic func strokeLine(startPoint:endPoint:color:attributes:)\nstatic func strokePath(path:startColor:endColor:angleInDegrees:attributes:)\n```\n\n\n### Fills\n\n```swift\nstatic func fillPath(path:startColor:endColor:angleInDegrees:attributes:)\n```\n\n### Geometry\n\nMany of the drawing methods use the geometry additions below, but they can also be useful for your own projects:\n\n```swift\nfunc divide(atDelta:fromEdge:margin:) -\u003e (slice, remainder)\nfunc insetBy(edgeInsets:) -\u003e CGRect\nmutating func insetInPlace(edgeInsets:)\nfunc alignedTo(rect:horizontal:vertical:) -\u003e CGRect\nfunc scaledTo(rect:scaleMode:) -\u003e CGRect\n\nfunc gradientPoints(forAngleInDegrees:) -\u003e (start, end)\nfunc scaledTo(size:scaleMode:) -\u003e CGSize\n\nfunc reversibleRect(fromPoint:toPoint:) -\u003e CGRect\n```\n\n### Images\n\nThere are also additional draw methods for images:\n\n```swift\nfunc drawAlignedTo(rect:horizontal:vertical:blendMode:alpha:)\nfunc drawScaledTo(rect:scaleMode:blendMode:alpha:)\n\nstatic func circle(radius:attributes:) -\u003e Image\nstatic func draw(width:height:scale:attributes:drawing:) -\u003e Image\nstatic func draw(size:scale:attributes:drawing:) -\u003e Image\n```\n\n### Strings\n\nFinally, we even have some easy draw methods for strings:\n\n```swift\nfunc drawAlignedTo(rect:horizontal:vertical:attributes:constrainedSize:)\nfunc sizeWithAttributes(attributes:constrainedSize:) -\u003e CGSize\nfunc drawAtPoint(point:attributes:)\nfunc drawInRect(rect:withAttributes)\n```\n\n## Demo\n\nTo try it out yourself, download the [source](http://github.com/shaps80/InkKit) and run the included demo project.\n\n## Platforms and Versions\n\nInkKit is supported on the following platforms:\n\n* iOS 8.0 and greater\n* OSX 10.11 and greater\n\n## Installation\n\nInkKit is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'InkKit'\n```\n\nAlternatively you can simply drag the files into your iOS or OSX project.\n\n\n## Author\n\n[@shaps](http://twitter.com/shaps)\n\n## License\n\nInkKit is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaps80%2Finkkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaps80%2Finkkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaps80%2Finkkit/lists"}