Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hboon/purplish-frame
Make working with rects, sizes and points more convenient with RubyMotion for iOS & OS X
https://github.com/hboon/purplish-frame
Last synced: 2 months ago
JSON representation
Make working with rects, sizes and points more convenient with RubyMotion for iOS & OS X
- Host: GitHub
- URL: https://github.com/hboon/purplish-frame
- Owner: hboon
- License: bsd-2-clause
- Created: 2015-12-03T21:13:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-14T05:54:13.000Z (almost 7 years ago)
- Last Synced: 2024-10-04T11:22:05.939Z (3 months ago)
- Language: Ruby
- Size: 29.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#Make working with rects, sizes and points more convenient with [RubyMotion](http://rubymotion.com) for iOS & OS X
Usage
---
For iOS & OS X:```ruby
rect = CGRectMake(10, -20, 100, 100)
rect.left
=> #10
rect.right
=> #110
rect.top
=> #-20
rect.bottom
=> #80
rect.width
=> #100
rect.height
=> #100
rect.center_x
=> #60
rect.center_y
=> #30
```Similar usage for UIView for iOS and NSView, NSSize, NSPoint, NSRect for OS X, CALayer for both platforms.
```ruby
rect = CGRectMake(10, -20, 100, 100)
rect.inset(5, 20)
=> # size=#>
```
Similar usage for UIView for iOS and NSView, NSRect for OS X, CALayer for both platforms.```ruby
CGSize.new(100, 100).scale_to_fit(CGSize.new(10, 10))
=> #CGSize.new(200, 100).scale_to_fill(CGSize.new(15, 15))
=> #CGSize.new(100, 100).scale_to_fit!
CGSize.new(200, 100).scale_to_fill!CGPoint.new(100, 200)*10
=> #CGPoint.new(100, 200)/10
=> #CGRectMake(10, 20, 100, 100).scale(10)
=> # size=#>
```Similar usage for NSSize, NSPoint, NSRect on OS X.
```ruby
img = UIImage.imageNamed('someImage')
img.width
=> 20.0
img.height
=> 30.0
```Similar usage for NSImage.
Installation
---
1. Add this to your `Gemfile`: `gem 'purplish-frame'`
2. Run `bundle install`License
---
BSD. See LICENSE file.Questions
---
* Email: [[email protected]](mailto:[email protected])
* Web: [http://hboon.com/](http://hboon.com/)
* Twitter: [http://twitter.com/hboon](http://twitter.com/hboon)