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
4
votes
2 answers

Problems with converting a CGPoint to a string

I have been having problems with converting a CGPoint to a string. I have tried various methods, but this seems like the most promising but it still won't work. Any suggestions? Here is my code: -(void)touchesMoved:(NSSet *)touches…
Jason
  • 91
  • 2
  • 6
4
votes
4 answers

Using CGPoints in an NSArray

I have been trying to create an array stating the location of a UIImageView in an app I've been working on. What I am trying to do is by using an array I can store the location of my "player" image by using its x,y and z coordinates. The script I…
Jason
  • 91
  • 2
  • 6
4
votes
1 answer

moving CGPoint a certain distance along a certain heading...iphone

this seems like such a simple problem but I have been unable to find an answer (and im no good at math). I am trying to move a UIView to a new CGPoint X distance away along a certain heading. What is the formula for determining the new…
Brodie
  • 3,526
  • 8
  • 42
  • 61
4
votes
2 answers

Convert CGPoint from CGRect to other CGRect

I have placed one label on view and view's frame is CGRectMake(0,0,270,203). Now I have to take screen shot of view with CGRectMake(0,0,800,600). So I have to convert label from old rect to new rect. here is code which I used to take screen…
Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56
4
votes
1 answer

CGPath adding a curve between points

So I have a function which randomly generates some CGPoints I then create a CGPath from these points. I use this path in a keyframe animation to animate a view around the screen. The path is generated using the code below: -…
Alec
  • 1,247
  • 2
  • 9
  • 9
4
votes
1 answer

Drawing a triangle

Im trying to allow users to draw a triangle shape. I'm getting the start point and the end point and using the formula to find the third point of a equilateral triangle to create the triangle but it doesn't seem to be working any ideas how I can do…
JProg
  • 189
  • 1
  • 9
  • 15
4
votes
2 answers

How to generate CGPoint-Array out of UIBezierPath (to touch-slide object along given path)

I have a UIBezierPath (curved like an '8', with only 4 points in it) and I need to make some kind of CGPoint-Array out of it. Any ideas? thanx! edit: I have my bezier initlialized like that -(void) initBezier { theBezierPath = [UIBezierPath…
headkit
  • 3,307
  • 4
  • 53
  • 99
3
votes
1 answer

IOS: use a gesture to calculate distance from two cgpoint

I have this code for gesture in a view - (void)rightSwipeHandle:(UIPanGestureRecognizer*)gestureRecognizer{ CGPoint touchBegan; CGPoint pointEnd; if (gestureRecognizer.state == UIGestureRecognizerStateBegan) { CGPoint…
cyclingIsBetter
  • 17,447
  • 50
  • 156
  • 241
3
votes
1 answer

Why does a node's position change when a CGFloat is used instead of a numeric literal?

Goal I want to set the position of a child node in my game's scene using the position property of SKSpriteNode and pass an inline mathematical expression as the argument to the y parameter. The child node I'm adding is a subclass of SKSpriteNode and…
3
votes
3 answers

Multiline text (wordwrap) with drawAtPoint?

is there a way to draw multiline text with drawAtPoint? I have tried UILineBreakModeWordWrap but doesnt seem to be working? How would you convert this code to a working multiline text?? point = CGPointMake(boundsX, 50); [self.heading…
George Asda
  • 2,119
  • 2
  • 28
  • 54
3
votes
2 answers

If statement with CGPoint

I need a example of how to use CGPoint with a if statement to check the x and y coordinates like something like this if(CGPoint == (XCORDINATE, YCORDINATE)){ do stuff } and then i need a example of how to check the x and y coordinates on a…
Jacob
  • 1,459
  • 2
  • 19
  • 32
3
votes
2 answers

Determining if UIView in array of UIView's overlap with each other at all, and then adjust position

I have a loop below that is supposed to detect if a view in an array of UIView's overlap with each other at all. If they do, then adjust their center value. Each view is 25x25. func drawCircles() { for i in 0..
narner
  • 2,908
  • 3
  • 26
  • 63
3
votes
1 answer

Add the middle point between two coordinates on a cgPath

We have a function that creates a path based on an array of CLLocationCoordinate2D, this array contains 4 coordinates, and will create a path with the shape of a square: func createPath(coordinates: [CLLocationCoordinate2D]) { for (index,…
SwiftyJD
  • 5,257
  • 7
  • 41
  • 92
3
votes
3 answers

Get the max and min values from an Array of CGPoints

We have an array of CGPoints: let points = [(1234.0, 1053.0), (1241.0, 1111.0), (1152.0, 1043.0)] What I'm trying to do is get the CGPoint with the highest x value and the one with the highest y value in the array. I will be using these points to…
SwiftyJD
  • 5,257
  • 7
  • 41
  • 92
3
votes
1 answer

Finding coordinates of gesture touch using locationOfTouch

Hey, been trying to get the location of a users swipe so that I can have 3 swipe-able areas on screen and determine which section they react with based on the y coordinates of their swipe. This is the code CGPoint touchPoint = [recognizer…
Wez
  • 10,555
  • 5
  • 49
  • 63