cgpoint

iPhone SDK: Convert MKMapPoint to CGPoint

∥☆過路亽.° 提交于 2019-12-01 01:39:58
问题 I have converted a longitude and latitude on my MapView to a MKMapPoint. I then want to move an imageView to that point using the imageViews center property. It seems that I somehow need to convert the MKMapPoint to a CGPoint so that I can change the center, but the numbers seem to be way off. Here is what I am using: // Convert to MKMapPoint CLLocationCoordinate2D coord; coord.latitude = [loc.latitude doubleValue]; coord.longitude = [loc.longitude doubleValue]; MKMapPoint point =

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

眉间皱痕 提交于 2019-11-30 15:51:52
问题 This question already has an answer here : Drag UIView around Shape Comprised of CGMutablePaths (1 answer) Closed 3 years ago . 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 bezierPath]; [theBezierPath moveToPoint:P(211.00, 31.00)]; [theBezierPath addCurveToPoint:P(870.00, 191.00) controlPoint1:P(432

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

♀尐吖头ヾ 提交于 2019-11-30 15:24:09
This question already has an answer here: Drag UIView around Shape Comprised of CGMutablePaths 1 answer 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 bezierPath]; [theBezierPath moveToPoint:P(211.00, 31.00)]; [theBezierPath addCurveToPoint:P(870.00, 191.00) controlPoint1:P(432.00, -11.00) controlPoint2:P(593.00, 209.00)]; [theBezierPath addCurveToPoint:P(731.00, 28.00) controlPoint1:P(1061.95, 178.53)

Rotating a CGPoint around another CGPoint

这一生的挚爱 提交于 2019-11-29 14:23:15
Okay so I want to rotate CGPoint(A) 50 degrees around CGPoint(B) is there a good way to do that? CGPoint(A) = CGPoint(x: 50, y: 100) CGPoint(B) = CGPoint(x: 50, y: 0) Here's what I want to do: This is really a maths question. In Swift, you want something like: func rotatePoint(target: CGPoint, aroundOrigin origin: CGPoint, byDegrees: CGFloat) -> CGPoint { let dx = target.x - origin.x let dy = target.y - origin.y let radius = sqrt(dx * dx + dy * dy) let azimuth = atan2(dy, dx) // in radians let newAzimuth = azimuth + byDegrees * CGFloat(M_PI / 180.0) // convert it to radians let x = origin.x +

applyImpulse towards CGPoint SpriteKit

懵懂的女人 提交于 2019-11-29 13:03:05
I'm kind of a newb in SpriteKit, game dev, as a matter of fact I'm just learning. So I got to a point where I what to move a bunch of nodes towards a users tap location. So far I fought that I might calculate a virtual right triangle and get sin and cos of angles based on the sides. Unfortunately that left me with a very strong impulse that doesn't really consider the user tap location. Any ideas? Thanks in advance. Look up the shooting projectiles section in the tutorial by Ray Wenderlich here: http://www.raywenderlich.com/42699/spritekit-tutorial-for-beginners Change the code from the

Getting Pixel Color from an Image using CGPoint in Swift 3

孤街醉人 提交于 2019-11-29 08:09:12
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: CGContextRef? var width: Int { get { return CGImageGetWidth(image) } } var height: Int { get { return CGImageGetHeight(image) } } init(img: CGImage) { image = img context = PixelExtractor.createBitmapContext(img) } class func createBitmapContext(img: CGImage) -> CGContextRef { // Get image width, height let pixelsWide = CGImageGetWidth(img) let pixelsHigh =

Converting a CGPoint to NSValue

早过忘川 提交于 2019-11-29 05:34:34
In CABasicAnimation.fromValue I want to convert a CGPoint to a "class" so I used NSValue valueWithPoint but in device mode or simulator one is not working... need to use NSMakePoint or CGPointMake if in device or simulator. ashcatch There is a UIKit addition to NSValue that defines a function + (NSValue *)valueWithCGPoint:(CGPoint)point See iPhone doc DanSkeel @ashcatch 's answer is very helpful, but consider that those methods from addition copy values, when native NSValue methods store pointers! Here is my code checking it: CGPoint point = CGPointMake(2, 4); NSValue *val = [NSValue

How to test if a point is in a view

不打扰是莪最后的温柔 提交于 2019-11-28 21:13:50
I have a UIImageView and I have a CGPoint on the screen. I want to be able to test that point to see if it is in the UIImageView . What would be the best way to do this? Deepak Danduprolu CGPoint is no good with a reference point. If your point is in window's coordinates then you can get it using CGPoint locationInView = [imageView convertPoint:point fromView:imageView.window]; if ( CGRectContainsPoint(imageView.bounds, locationInView) ) { // Point lies inside the bounds. } You may also call pointInside:withEvent: method if ( [imageView pointInside:locationInView withEvent:nil] ) { // Point

Coordinates all wrong on iPhone 3G? It could be your compiler

房东的猫 提交于 2019-11-28 12:01:52
Note: This is question to which I have already found an answer. It seems that posting a question after finding an interesting answer is encouraged , so I am posting this. Someone else is likely to have the same problem and find this useful. I have an iOS app that produces charts. Shortly after publishing an update, a user sent me this panicky email: "the latest update has modified the curves ... not seen more growth curves and inserted data are represented as a line descending ... before you could see perfectly well Help me" I get him to send a screenshot and give more detail. He has an iPhone

How to convert CGPoint in NSValue in swift?

混江龙づ霸主 提交于 2019-11-28 11:55:04
As my question title says how can I convert CGPoint into NSValues so I can store then Into array In swift . In objective-C we can do it like this: // CGPoint converted to NSValue CGPoint point = CGPointMake(9, 9); NSValue *pointObj = [NSValue valueWithCGPoint:point]; But can anybody tell me that how can I do this in swift? Thanks In Advance. Try something like that: let point = CGPointMake(9, 9) var pointObj = NSValue(CGPoint: point) Exactly as you'd imagine: let point = CGPoint(x: 9.0, y: 9.0) let pointObj = NSValue(CGPoint: point) let newPoint = pointObj.CGPointValue() Abizern If you aren't