Skip to content
/ CropView Public
forked from rzmn/CropView

Crop rectangle view like in Notes App

License

Notifications You must be signed in to change notification settings

Weang/CropView

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CropView

Quadrangle view and image cropper like a Notes App

Demo

Screenshot

Usage

Initialization

Set initial coordinates in points

cropView.configureWithCorners(corners: [CGPoint(x: 120, y: 100),
                                        CGPoint(x: 270, y: 170),
                                        CGPoint(x: 280, y: 450),
                                        CGPoint(x: 120, y: 400)], on: imageView)

Customisation

Customize color of your corners/contour and corners size

// SECornerView.swift
static var cornerSize : CGFloat = 50.0
// SECropView.swift
static var goodAreaColor = #colorLiteral(red: 0.4666666687, green: 0.7647058964, blue: 0.2666666806, alpha: 1)
static var badAreaColor  = #colorLiteral(red: 0.9254902005, green: 0.2352941185, blue: 0.1019607857, alpha: 1)

Geometry

// SEQuadrangleHelper.swift

// Crop image by quadrangle points in pixels
static public func cropImage(with image: UIImage, quad: [CGPoint]) throws -> UIImage
// get image frame in UIImageView and convert quadrangle coordinates into image pixels
static public func getCoordinatesOnImageWithoutScale(on imageView: UIImageView, with cropView: SECropView) throws -> Array<CGPoint>
// get quadrangle coordinates, related by UIImageView frame in pixels
static public func getCoordinatesOnImageView(on imageView: UIImageView, with cropView: SECropView) throws -> Array<CGPoint>

About

Crop rectangle view like in Notes App

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.6%
  • Ruby 3.4%