开发者

Resize drawing animation from given CGPoints?

开发者 https://www.devze.com 2023-02-11 23:37 出处:网络
I have an iphone version of an App that draws lines on the screen from CGPoints that are stored in a Core Data. all of the drawings are line based without any fill, so basically it draws a line from g

I have an iphone version of an App that draws lines on the screen from CGPoints that are stored in a Core Data. all of the drawings are line based without any fill, so basically it draws a line from given point to the next point etc.

Now i am making an iPad version and i want to use the same points (The points were collected with a function I build for tracking the screen and it was a lot of work so I wish to reuse the same points i have).

Does any body has an idea, algorithm or function for drawing the same lines' from the same points but X2 size ?

That 开发者_运维知识库is the draw method:(took it from the GLPaint example of apple)

- (void) playback:(NSNumber*)index 
{

    if (p==0) {
        pointsCount=[[localpoints objectAtIndex:[index intValue]] count]-1;
    }

    isPlayBackOn = YES;

    LetterPoint *point1 = (LetterPoint*)[[localpoints objectAtIndex:[index intValue]] objectAtIndex:p];
    CGPoint p1 = CGPointFromString(point1.float_point);
    LetterPoint *point2 = (LetterPoint*)[[localpoints objectAtIndex:[index intValue]] objectAtIndex:p+1];
    CGPoint p2 = CGPointFromString(point2.float_point);

    [self renderLineFromPoint:p1 toPoint:p2];

    p++;    

    if(p<pointsCount){
        [self performSelector:@selector(playback:) withObject:index afterDelay:0.03];
    }else {
    p=0;
        isPlayBackOn = NO;
    }
}

thanks

shani


Create an affine transform matrix with a scale factor of 2.0 (and possibly a translation if you want to move the origin of the drawing). Then apply that transform to every point with CGPointApplyAffineTransform() and use the resulting points for drawing.


well, just double p1.x and p1.y... transform it just with this:

instead of:

CGPoint p1 = CGPointFromString(point1.float_point);

do this:

CGPoint p1Temp = CGPointFromString(point1.float_point);
CGPoint p1 = CGPointMake(p1Temp.x * 2, p1Temp.y * 2);

and the same for p2...

0

精彩评论

暂无评论...
验证码 换一张
取 消