GithubHelp home page GithubHelp logo

paulz / imagecoordinatespace Goto Github PK

View Code? Open in Web Editor NEW
56.0 6.0 14.0 744 KB

UICoordinateSpace for UIImageView image

License: MIT License

Objective-C 0.65% Swift 89.51% Ruby 9.84%
xcode carthage swift face-detection swift-5 playground cocoapod coverage

imagecoordinatespace's Introduction

Image Coordinate Space

UICoordinateSpace for UIImageView image

CI codecov Depfu

Swift Version License Platform Carthage compatible

Usage

Convert CGPoint from image coordinates to view coordinates:

import ImageCoordinateSpace

let imageSpace = imageView.contentSpace()
let imageTopLeft = imageSpace.convert(CGPoint.zero, to: imageView)

Convert CGPoint from view coordinates to image coordinates:

let viewTopLeft = imageSpace.convert(CGPoint.zero, from: imageView)

Similar conversions are available for CGRect:

let imageRect = CGRect(x: 321, y: 102, width: 63, height: 64)
let viewRect = imageSpace.convert(imageRect, to: imageView)

and from view coordinates to image coordinates:

let viewRect = CGRect(x: 107, y: 68, width: 21, height: 42.667)
let imageRect = imageSpace.convert(viewRect, from: imageView)

Examples

Add positioned image overlay

Open included Xcode Example project to see Xcode Playground: Example/Visual.playground

Demonstrate image ovelay placement

Converting image face detection regions to view touch points

Other uses from popular Stackoverflow questions:

Documentation

HeaderDoc is included, see UIImageView+UICoordinateSpace.swift

Installation

  • add the following line to your Podfile:

pod 'ImageCoordinateSpace'

  • run pod install
  • add to your Cartfile:

    github "paulz/ImageCoordinateSpace"

  • run carthage update

  • link your app with ImageCoordinateSpace.framework from Carthage/Build/iOS folder

Unit tests

To run included unit tests install dependencies via Carthage:

carthage bootstrap

Run tests:

xcodebuild test -scheme ImageCoordinateSpace -destination 'platform=iOS Simulator,name=iPhone 11 Pro'

See them pass at lightning speed:

Test Suite 'All tests' passed at 2017-12-13 08:07:14.826.
Executed 36 tests, with 0 failures (0 unexpected) in 0.013 (0.023) seconds
** TEST SUCCEEDED **

Author

Paul Zabelin, https://github.com/paulz

License

ImageCoordinateSpace is available under the MIT license. See the LICENSE file for more info.

imagecoordinatespace's People

Contributors

amigodeveloper avatar dependabot-preview[bot] avatar dependabot-support avatar juliankniephoff avatar paulz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

imagecoordinatespace's Issues

Mismatch between Cocoapods and Repo code?

I'm seeing huge differences between the code available in Cocoapods and the repo here in GH. Maybe Swift3 code??

Could there be an update pending? I'm interested in using this lib to skip doing some manual transformations, but as it is it won't build out of the box.

An example is

class TransformedCoordinateSpace : NSObject, UICoordinateSpace {
...
}

This class declaration is already different than what the repo in GH has, where declaration is ClassName: NSObject and the second extension is handled in an extension tag right below.

https://github.com/paulz/ImageCoordinateSpace/blob/master/ImageCoordinateSpace/TransformedCoordinateSpace.swift

Upgrade to Swift 3.0

The library doesn't work with swift 3.0 projects.

Help would be appreciated since it's the only library out on the web that allows coordinate conversions between image space and screen space.

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.