Questions tagged [cgpoint]

CGPoint is a structure from Apple's Core Graphics framework. It is used to represent a point in two dimensions.

CGPoint is a C struct that contains information about the location of a point in two dimensions.

Fields:

  • x: The X location of the point
  • y: The Y location of the point
509 questions
3
votes
3 answers

How to convert CGRect to CGPoint iOS Swift

Here i want to convert UIImageView's maxY CGRect value to CGPoint, but when i tried to convert CGRect value to CGPoint i got an error. Code let cgPoint = imgPin.convert(imgPin.frame.minY, to: self.view) Error Expression type '@lvalue CGRect'…
steveSarsawa
  • 1,559
  • 2
  • 14
  • 31
3
votes
1 answer

Animate a view alongside a path without CAKeyframeAnimation

I want to animate a view alongside a path (without CAKeyframeAnimation) instead with UIViewPropertyAnimator. For that I have a path with start- and endpoint and a controlpoint to make a quadcurve. let path = UIBezierPath() path.move(to:…
kuemme01
  • 472
  • 5
  • 19
3
votes
1 answer

ios - Convert CGPoints (CIRectangleFeature) from Image to ImageView

I am creating an iPhone app that detects Rectangle and captures image using Camera. I create an overlay over the biggest rectangle detected and once captured i have 4 CGPoints using CIRectangleFeature and an Image. All 4 points in…
Hassy
  • 5,068
  • 5
  • 38
  • 63
3
votes
1 answer

Swift 3 Beginner - Position Assets in Scene

I am a complete beginner at Swift 3 and programming in general so this will be an incredibly basic question. I have been following tutorials and am currently positioning a SpriteNode using CGPoint. The tutorial recommends the following to position…
Martin Jones
  • 123
  • 7
3
votes
4 answers

Getting Pixel Color from an Image using CGPoint in Swift 3

I am try this PixelExtractor class in Swift 3, get a error; Cannot invoke initializer for type 'UnsafePointer' with an argument list of type '(UnsafeMutableRawPointer?)' class PixelExtractor: NSObject { let image: CGImage let context:…
Neil Lee
  • 33
  • 1
  • 4
3
votes
3 answers

Swift - Textview Identify Tapped Word Not Working

Long time user, first time poster, so my apologies if I make any errors in presenting my question. I have been working on this for hours and I've decided it is time to ask the experts. I have also searched through every similar question that has…
Jake Braden
  • 489
  • 5
  • 15
3
votes
3 answers

Performance - structs in NSValue vs container object

In a situation where I need to save all data members in a NSDictionary, does it make more sense to put structs (custom types, or even scalars i.e. CGPoint) in my own wrapper (not NSValue), so I can avoid the overhead of encoding/decoding it every…
Morrowless
  • 6,856
  • 11
  • 51
  • 81
3
votes
1 answer

Spawn a SKSpriteNode between two positions randomly

I am trying to work out how to spawn a SKSpriteNode between two positions (located on the screen) randomly in Swift. This is what I came up with, but it does spawn Nodes outside the screen dimensions altough I defined two points inside the screen…
Devapploper
  • 6,062
  • 3
  • 20
  • 41
3
votes
1 answer

Shortest distance from CGPoint to segment

I've been trying to implement Douglas-Peucker algorithm into my code and I'm able to translate pseudocode into Swift, except for the shortestDistanceToSegment function. Only Swift version I could find was answered here but I don't understand what…
Aleksi Sjöberg
  • 1,454
  • 1
  • 12
  • 34
3
votes
2 answers

get CGPoint inside didSelectItemAtIndexPath method of CollectionView

Is there a way that I can get coordinates of clicked point inside collectionViewCell? I want to do method A if I clicked at rect with Y coordinate < 50, and method B if Y >50.
AleksandarNS
  • 265
  • 1
  • 2
  • 15
3
votes
2 answers

Get random CGPoint on CGPath

I have a CGPath that represents an ellipse. I'd like to place a sprite node at a random point on that path. How can I get a random CGPoint on that CGPath?
JuJoDi
  • 14,627
  • 23
  • 80
  • 126
3
votes
0 answers

Get non-scaled touch point of zoomed UIWebView

I want to get CGPoint of a touch on UIWebview but I want to able to get exact same point when user hasnt zoomed yet and after zoomed. So lets say user longtapped a point without zooming and below method returns point {185.5, 303} for that point,…
SpaceDust__
  • 4,844
  • 4
  • 43
  • 82
3
votes
1 answer

If with CGPointEqualToPoint do not work

Im trying to figure out why this function do not execute theGameEnd function, when ball position is exactly the same as block position and when anchorpoints are the same. if (CGPointEqualToPoint(ball.position,block.position)) { if…
3
votes
2 answers

Convert geographic coordinates to a CGPoint on a custon=m UIView

I'm building a application in whom one of the features will be shoving geographic coordinates on a custom UIImageView. I'm bad at math so I cant seem to get the right values. This is what I'm doing: I have a image that is 2048x2048 and I put it in a…
3
votes
2 answers

Turn NSArray of CGPoints into a block of NSData

I am trying to turn a NSArray of CGPoints to NSData. I can't figure out how to do it. According to http://www.raywenderlich.com/12910/how-to-make-a-simple-playing-card-game-with-multiplayer-and-bluetooth-part-3 NSString *string = @"example" …
fftoolbar
  • 175
  • 1
  • 1
  • 11