Git Product home page Git Product logo

uibezierpath-superpowers's People

Contributors

codingmeswiftly 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  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

uibezierpath-superpowers's Issues

Release Crashing

Been using the code no problems for days. Sent out a beta and it crashes for everyone. I don't know why, but it seems that when it gets to this point it crashes:
block?(element.pointee)

I could only get it to crash doing a release build and I'm not proficient enough at swift to understand why it's failing.

Searching around for ideas/code I ran across this devforum post (notably Eskimo's):
https://forums.developer.apple.com/message/15725#15725

I used this code he posted:

typealias CGPathApplierBlock = @convention(block) (CGPathElement) -> Void

extension CGPath {
func apply(body: CGPathApplierBlock) {
self.apply(info: unsafeBitCast(body, to: UnsafeMutableRawPointer.self)) { (info, element) in
let block2 = unsafeBitCast(info, to: CGPathApplierBlock.self)
block2(element.pointee)
}
}
}

And now instead of:
enumeratePathElements { element in

I use:
cgPath.apply { element in

And it works without crashing in debug and release build. I'm building with xcode 9.1 and most testing on iOS 11 devices.

[Feature] Cocoa support

Thanks for writing this! I want almost this exact thing, except for NSBezierPath (I'm not writing a iOS app, I'm driving a laser cutter from my Mac).

I'm going to give writing the NSBezierPath version a shot.

Crash when running calculations with zero length path elements.

It is possible to build a UIBezierPath consisting of "points" rather than actual line elements. In that case point is a zero length line element.

Example:

let p: CGPoint = ...
path.move(to: p)
path.addLine(to: p)

The current implementation does not account for this possibility.
Most notably, findPathElement(at:, callback:), which is basically the spine of the library, will search for path elements based on their lengthRange. Things start to burn all over the place when this range is 0...0, which it is for "points".

See #1

minor nit

I'm using mx_perpendicularPoint so when a user taps on the screen we can highlight the nearest "drawing object".

Sometimes a line segment might not have a length (i.e. user touched/released to make a dot), but it is visible because of setLineCapStyle:kCGLineCapRound.

In calculatePointLookupTable it doesn't take into account a single point "path" like this, element.length is zero and points.append(element.point(at: offset / element.length)) fails because offset is divided by zero producing Nan for an index.

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.