*   >> Чтение Образование Статьи >> science >> programming

Iphone Рисование на изображение части 1

.width /320;;

<р>} size.height /460
<р> = newHeight myPic.size.height /отношение;

<р> = newWidth myPic.size.width /отношение;

<р> [myPicdrawInRect: CGRectMake (0,0, newWidth, newHeight)] ;

<р>}

<р>, если ([myDrawingcount]> 0) {

<р> CGContextSetLineWidth (CTX, 5);

<р> для (INT I = 0; я <р> NSArray * thisArray = [myDrawingobjectAtIndex: я];

<р>, если ([thisArray число]> 2) {

<р> плавать thisX = [[thisArray objectAtIndex: 0] floatValue] < ш>

плавать thisY = [[thisArray objectAtIndex: 1] floatValue];

<р> CGContextBeginPath (CTX);

<р> CGContextMoveToPoint (CTX, thisX, thisY);

<р> для (INT I = 2, J <р> thisX = [[thisArray objectAtIndex: J] floatValue];

<р> thisY = [[thisArray objectAtIndex: J + 1] floatValue];

<р> CGContextAddLineToPoint (CTX, thisX, thisY);

<р>}

<р> CGContextStrokePath (CTX);

<р>}

<р>}

<р>}

<р>}

<р> - (недействительными) touchesBegan: (NSSet *) касается withEvent: (UIEvent *) событие {

<р> [myDrawingaddObject: [[NSMutableArrayalloc] initWithCapacity: 4]];
<р> CGPoint curPoint = [[штрихи anyObject] locationInView: само];

<р> [[myDrawinglastObject] AddObject: [NSNumbernumberWithFloat: curPoint.

x]];

<р> [[myDrawinglastObject] AddObject: [NSNumbernumberWithFloat: curPoint.y]];

<р>}

<р> - (недействительными) touchesMoved: (NSSet *) касается withEvent: (UIEvent *) событие {

<р> CGPoint curPoint = [[штрихи anyObject] locationInView: само];

<р> [[myDrawinglastObject] AddObject: [NSNumbernumberWithFloat: curPoint.x]];

<р> [[myDrawinglastObject] AddObject: [NSNumbernumberWithFloat: curPoint.

y] ];

<р> [selfsetNeedsDisplay];

<р>}

<р> - (недействительными) touchesEnded: (NSSet *) касается withEvent: (UIEvent *) событие {

<р> CGPoint curPoint = [[штрихи anyObject] locationInView: само];

<р> [[myDrawinglastObject] AddObject: [NSNumbernumberWithFloat: curPoint.x]];

<р> [[myDrawinglastObject] addObject:[NSNumbernumberWithFloat:curPoint.

y]];

[selfsetNeedsDisplay];

}

-(void)cancelDrawing {

<р> [myDrawingremoveAllObjects];

<р> [selfsetNeedsDisplay];

<р>}

<р> - (недействительными) dealloc {

[superdealloc];

[myPicrelease];

[myDrawingrelease];

}

@end

Every раз, когда вы коснуться экрана, - (недействительными) метод touchesBegan делает точку в массиве myDrawing, а затем отображает его через -. (пустот) методом Dra

Page   <<  [1] [2] [3] [4] >>
Copyright © 2008 - 2016 Чтение Образование Статьи,https://ru.nmjjxx.com All rights reserved.