{"id":13743106,"url":"https://github.com/agens-no/AGGeometryKit","last_synced_at":"2025-05-09T00:32:53.554Z","repository":{"id":7043857,"uuid":"8321923","full_name":"agens-no/AGGeometryKit","owner":"agens-no","description":"Quadrilaterals on CALayer, CGGeometry-functions, UIView/CALayer properties and other invaluable tools.","archived":false,"fork":false,"pushed_at":"2018-10-25T07:39:56.000Z","size":6262,"stargazers_count":1266,"open_issues_count":7,"forks_count":130,"subscribers_count":47,"default_branch":"master","last_synced_at":"2024-10-29T18:08:28.138Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agens-no.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":"2013-02-20T20:52:18.000Z","updated_at":"2024-08-26T09:25:06.000Z","dependencies_parsed_at":"2022-09-13T22:52:07.602Z","dependency_job_id":null,"html_url":"https://github.com/agens-no/AGGeometryKit","commit_stats":null,"previous_names":["hfossli/aggeometrykit"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agens-no%2FAGGeometryKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agens-no%2FAGGeometryKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agens-no%2FAGGeometryKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agens-no%2FAGGeometryKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agens-no","download_url":"https://codeload.github.com/agens-no/AGGeometryKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224238174,"owners_count":17278472,"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":[],"created_at":"2024-08-03T05:00:40.661Z","updated_at":"2024-11-15T14:30:56.214Z","avatar_url":"https://github.com/agens-no.png","language":"Objective-C","readme":"# \u003cimg src=\"/logo.png?raw=true\" width=\"191\" alt=\"AGGeometryKit\" /\u003e\n[![Build Status](https://travis-ci.org/agens-no/AGGeometryKit.svg?branch=master)](https://travis-ci.org/agens-no/AGGeometryKit)\n\nQuadrilaterals on CALayer (control each corner point individually), CGGeometry-functions, UIView/CALayer properties and other invaluable tools.\n\n\n\n### Installation\n\n```ruby\npod 'AGGeometryKit'\n```\n\n##### Import in swift\n\n```swift\nimport AGGeometryKit\n```\n\n##### Import in Objective-C\n\n```objective-c\n#import \u003cAGGeometryKit/AGGeometryKit.h\u003e\n```\n\n## Demo\n\n[![Demo video](/video-aggeometrykit.png)](https://vimeo.com/95376358)  \n[See the video on vimeo ](https://vimeo.com/95376358)\n\nUsed in conjunction with [POP](https://github.com/facebook/pop) this allows you to do really awesome stuff. Visit [AGGeometryKit+POP](https://github.com/hfossli/AGGeometryKit-Pop).\n\n[![Demo video](/video-aggeometrykit-pop.png)](https://vimeo.com/95383807)  \n[See the video on vimeo ](https://vimeo.com/95383807)\n\n\n## Quadrilaterals\n\nA quadrilateral is a polygon with four sides (or edges) and four vertices or corners. AGGeometryKit lets you control each corner point individually.\n\nYou can access `quadrilateral` as a property just like you would do with `frame`, `center` or `bounds`. The coordinates is in same coordinate system as `frame` and `position`. You can use the quadrilateral on any UIView or CALayer - even webviews - with just as good performance as you would have not using it. The underlying technology is CATransform3D. More about quadrilaterals: http://en.wikipedia.org/wiki/Quadrilateral\n\n```objective-c\nUIView *view = ...; // create a view\n[view.layer ensureAnchorPointIsSetToZero]; // set the anchor point to [0, 0] (this method keeps the same position)\n\nAGKQuad quad = view.layer.quadrilateral;\nquad.br.x += 20; // shift bottom right x-value with 20 pixels\nquad.br.y += 50; // shift bottom right y-value with 50 pixels\n\nview.layer.quadrilateral = quad; // the quad is converted to CATransform3D and applied\n```\n\n## UIView and CALayer properties\n\nExample of some of the properties which is added to UIView and CALayer. Naming is done in same manner as `CGRectGetMaxX` for consistency.\n\n```objective-c\n...\n@property (nonatomic, assign) CGPoint frameOrigin;\n@property (nonatomic, assign) CGFloat frameMinX;\n@property (nonatomic, assign) CGFloat frameMinY;\n@property (nonatomic, assign) CGFloat frameMidX;\n@property (nonatomic, assign) CGFloat frameMidY;\n@property (nonatomic, assign) CGFloat frameMaxX;\n@property (nonatomic, assign) CGFloat frameMaxY;\n@property (nonatomic, assign) CGFloat frameWidth;\n@property (nonatomic, assign) CGFloat frameHeight;\n...\n```\n\n\n\n## CGGeometry-additions\n\nSome of the most useful functions\n\n```objective-c\n...\nCGRect  CGRectInterpolate_AGK(CGRect rect1, CGRect rect2, CGFloat progress);\nCGSize  CGRectGapBetween_AGK(CGRect rect1, CGRect rect2);\nCGPoint CGPointClamp_AGK(CGPoint p, CGFloat minX, CGFloat maxX, CGFloat minY, CGFloat maxY);\nCGPoint CGPointAdd_AGK(CGPoint p1, CGPoint p2);\n...\n```\n\n\n\n## Math\n\nSome of the most useful functions\n\n```objective-c\n...\nCGFloat AGKInterpolate(CGFloat startValue, CGFloat endValue, CGFloat progress);\nCGFloat AGKRemapToZeroOne(CGFloat value, CGFloat startValue, CGFloat endValue);\nCGFloat AGKRemap(CGFloat value, CGFloat oldStartValue, CGFloat oldEndValue, CGFloat newStartValue, CGFloat newEndValue);\nCGFloat AGKRemapAndClamp(CGFloat value, CGFloat oldStartValue, CGFloat oldEndValue, CGFloat newStartValue, CGFloat newEndValue);\nCGFloat AGKRemapToZeroOneAndClamp(CGFloat value, CGFloat oldStartValue, CGFloat oldEndValue);\nCGFloat AGKClamp(CGFloat value, CGFloat min, CGFloat max);\n\nCGFloat AGKRadiansToDegrees(CGFloat radians);\nCGFloat AGKDegreesToRadians(CGFloat degrees);\n...\n```\n\n\n## Debugging quadrilaterals\n\n- anchorPoint must be {0, 0} always when using quadrilaterals\n- the quadrilateral must be convex\n- don't modify the frame, but instead use `layer.position` or `view.center` and `layer.bounds` or `view.bounds`\n- quadrilateral can not be used in conjunction with other CATransform3D-things like perspective, scale, rotate etc\n- remember the coordinate system for the `quadrilateral`-property is in the same coordinate as `frame` and `position`\n- check if the autoresizing mask might be altering the frame (to be 100% sure it is good for debugging to turn off `autoresizesSubviews`)\n\nIt can also be useful to create a representation of the quadrilateral you are trying to display using a UIBezierPath:\n\n```objective-c\nUIView *quadPreview = [[UIView alloc] init];\nquadPreview.frame = quadView.frame;\nquadPreview.layer.shadowPath = [UIBezierPath bezierPathWithAGQuad:quad].CGPath;\nquadPreview.layer.shadowColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.5].CGColor;\nquadPreview.layer.shadowOpacity = 1.0;\nquadPreview.layer.shadowRadius = 0.0;\nquadPreview.layer.shadowOffset = CGSizeZero;\nquadPreview.backgroundColor = [UIColor clearColor];\n[quadView.superview addSubview:quadPreview];\n```\n\n\n## Useful links\n\n* Bartosz Ciechanowski created a [genie effect](https://github.com/Ciechan/BCGenieEffect/) around december 2012 using quadrilaterals\n* [Quadrilaterals on stackoverflow](http://stackoverflow.com/a/12820877/558816)\n* Want to work with us? Visit [agens.no](http://agens.no/)\n\n\n\n## Keywords\n\nConvex quadrilateral, simple quadrilateral, tangential, kite, rhombus, square, trapezium, trapezoid, parallelogram, bicentric, cyclic\n\n\n\n## Contact\n\nYou can reach me on twitter as [@hfossli](https://twitter.com/hfossli).\n\n\n## Who's behind this?\n\nAgens.no a company situated in Oslo, Norway with some help from some very clever stackoverflow.com guys.\n\n[\u003cimg src=\"http://static.agens.no/images/agens_logo_w_slogan_avenir_medium.png\" width=\"340\" /\u003e](http://agens.no/)\n","funding_links":[],"categories":["Objective-C  Stars 1000以内排名整理","etc"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagens-no%2FAGGeometryKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagens-no%2FAGGeometryKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagens-no%2FAGGeometryKit/lists"}