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

How to get a centerpoint from an array of cgpoints?

I 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 find the center of the CGPoints. So I can place an object at the center of all the points. If this was an array of lets say…
SwiftyJD
  • 5,257
  • 7
  • 41
  • 92
2
votes
1 answer

How to animate object using bezier path?

Here is my code to draw dashed line func drawLine() { let shapeLayer = CAShapeLayer() shapeLayer.bounds = viewDraw.bounds shapeLayer.position = CGPoint(x: viewDraw.bounds.width/2, y: viewDraw.bounds.height/2) shapeLayer.fillColor =…
Jitendra Modi
  • 2,344
  • 12
  • 34
2
votes
1 answer

Restoring CGRect with Transform values from NSDictionary

I need to be able to save the frame after transformation of a UIImageView. In the below example, the original frame is when the image is added to the superview. The user then has the ability to rotate, scale and pan the image anywhere in the gray…
WrightsCS
  • 50,551
  • 22
  • 134
  • 186
2
votes
0 answers

SpriteKit SKNodes position value is changing 64 bit CGFloat to 32 bit

I am having an issue with my SKShapeNode and SKCameraNode changing from a 64bit value to 32bit. I need very specific values otherwise my SKCameraNode will start to become jittery when I move in too much. The value changes when I calculate a position…
samster
  • 142
  • 1
  • 2
  • 9
2
votes
1 answer

Setting Position of SKSpriteNode in Swift 4

So below, I have one SKSpriteNode image that I'm also animating using Texture Atlas along SKAction.animate to animate through one of my texture arrays. When I first run the app, the image shows up directly in the center of the screen and animates…
Dewan
  • 429
  • 3
  • 16
2
votes
5 answers

Binary operator (*) cannot be applied to operands CGPoint and CGFloat

I am trying to add gravity and velocity to a player but can't fix this error. I've tried multiple different things but always get the same type of error. Could anyone tell what I am doing wrong and why its not possible to use multiply a CGPoint and…
Yes
  • 43
  • 4
2
votes
1 answer

iOS - How to get CGPoint at a specified distance along a line?

Is there an easy way to do this. I have a CGPoint pointA (10, 10) and another CGPoint pointB (15, 8). I need to get a CGPoint which is on the same line as the one connecting A and B and at a certain distance (say 2) before point A. I tried looking…
OutOnAWeekend
  • 1,383
  • 1
  • 18
  • 36
2
votes
1 answer

Trimming a straight line (2 CGPoint) inside a CGRect

Given a CGRect and a line created with 2 CGPoint is there a way to find the coordinates where the line intersects with the rect? From the previous image: what I'm trying to achieve is to substitute the dots outside the rectangle with the red dots…
MatterGoal
  • 16,038
  • 19
  • 109
  • 186
2
votes
0 answers

need to change positioning of labels using cgpoint (swift3)

I have two labels. One lane occupies the top left section of the screen and the other occupies the top right section of the screen. Even though it states bottom alignment mode the position is still on the top of the screen scoreLabel.text = "…
user7263280
2
votes
1 answer

Round CGPoint location

In my application I am developing a sort of tile system. Instead of doing my tiles manually I am planning on having UIImageViews that "snap" to a specific location. Here's my question: How can I round my new location to a factor of (in my case) 16?
Matt S.
  • 13,305
  • 15
  • 73
  • 129
2
votes
1 answer

CGPointFromString in Xamarin

Is there an equivalent function available in Xamarin.iOS for CGPointFromString I looked at online Xamarin API documents and nothing that I found relevant.
Renish
  • 76
  • 8
2
votes
2 answers

Rotating CGPoint around a center point

I have been trying to find an example of using the 2D transform matrix to rotate a CGPoint around the center of another CGPoint but I've had no luck finding anything recent. Has anyone managed to achieve this? Using CGAffineTransform isn't an…
bevbomb
  • 689
  • 2
  • 12
  • 26
2
votes
1 answer

Calculating the distance CGPoint travelled from one place to another

What method do I have to use for calculating the distance that CGPoint travelled from its old position to new position? var point: CGPoint = CGPointMake(x:50.0, y:50.0) ...and there is a method for dragging a point with LMB: func…
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
2
votes
1 answer

Get specific corner co-ordinates of UIView/UIImageView irrespective of its rotation

I have a simple UIImageView of in my screen as follow: To get the co-ordinates of highlighted corner of this UIImageView, I use simple formula: CGPointMake(CGRectGetMaxX(imageView.frame), CGRectGetMaxY(imageView.frame)) Now I rotate this imageView…
Rohan Sanap
  • 2,773
  • 2
  • 21
  • 39
2
votes
3 answers

Placing UILabel in the center of screen

I have a UILabel which I want to be displayed at the center of screen regardless of which iPhone it is played on! But I can't get it right! It's always somewhere else but not in the middle. what am i doing wrong? Here is the picture and code of…
Osaama Shehzad
  • 147
  • 1
  • 2
  • 12