I have this code, where location and previousLocation are two CGPoint:
CGRect bounds = [self bounds];
UITouch *touch = [[event touchesForView:self] anyObject];
CGPoint point = [touch locationInView:self];
location = CGPointMake(point.x,point.y);
location.y = bounds.size.height - location.y;
CGPoint prev = [touch previousLocationInView:self];
previousLocation = CGPointMake(prev.x, prev.y);
previousLocation.y = bounds.size.height - previousLocation.y;
[self renderLineFromPoint:previousLocation toPoint:location];
ok this is a part of code that is inside “touchmoved” of my GLPaint application; but my problem is that I want shift location and previousLocation in a fix point, this point in a vertex of an imageview (I do it because I drag an image when i touch view) and value of this point could be as:
CGPoint *vertex = (imageView.center.x-100, imageView.center.y+100);
so my code change in:
CGRect bounds = [self bounds];
UITouch *touch = [[event touchesForView:self] anyObject];
//CGPoint point = [touch locationInView:self];
location = CGPointMake(vertex.x,vertex.y);
location.y = bounds.size.height - location.y;
//CGPoint prev = [touch previousLocationInView:self];
previousLocation = CGPointMake(prev.x, prev.y); <---- ?????
previousLocation.y = bounds.size.height - previousLocation.y;
[self renderLineFromPoint:previousLocation toPoint:location];
location can be changed easily but my problem now is previousLocation, how I can change it? Then my question is…what’s the way to know differences from location to previousLocation? How can I calculate its difference? So if I know the dinamic difference I can set a correct shift previousLocation…
this is solution: