quartz-2d

Animating the drawing of a line

爷,独闯天下 提交于 2019-12-05 04:52:10
I'm trying to animate the drawing of a line by the following way: .h CAShapeLayer *rootLayer; CAShapeLayer *lineLayer; CGMutablePathRef path; .m path = CGPathCreateMutable(); CGPathMoveToPoint(path, nil, self.frame.size.width/2-100, 260); CGPathAddLineToPoint(path, nil, self.frame.size.width/2+100.0, 260); CGPathCloseSubpath(path); self.rootLayer = [CALayer layer]; rootLayer.frame = self.bounds; [self.layer addSublayer:rootLayer]; self.lineLayer = [CAShapeLayer layer]; [lineLayer setPath:path]; [lineLayer setFillColor:[UIColor redColor].CGColor]; [lineLayer setStrokeColor:[UIColor blueColor]

Writing with digital pen on ipad/iphone by keeping hand on screen

会有一股神秘感。 提交于 2019-12-05 03:50:18
问题 I am working on a drawing app, with pen touch, on iphone and ipad. Till now , I have implemented the basic drawing and tested with digital pen and it work fine, but I have one issue, while drawing on iphone/ipad, if my fingers touch the screen before I draw with pen , the pen wont work, So what I want to achieve is that, I want to able to write with pen, even if my fingers are touching the ipad screen. Regards Ranjit 回答1: There is no way to differentiate between a finger and a stylus, as a

Saving a PDF document to disk using Quartz

谁说胖子不能爱 提交于 2019-12-05 02:38:31
问题 I am trying to draw a pdf page onto a pdf context and then save it to disk. I cannot seem to figure out what is wrong. Can someone give me a few pointers. Thanks. - (void)testQuartz:(NSData *)pdfDocumentData { //Create the pdf document reference CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((CFDataRef)pdfDocumentData); CGPDFDocumentRef document = CGPDFDocumentCreateWithProvider(dataProvider); CGDataProviderRelease(dataProvider); //Release the data provider //Create the pdf

iPhone App - Display pixel data present in buffer on screen

蓝咒 提交于 2019-12-04 23:29:49
I have the source code for a video decoder application written in C, which I'm now porting on iphone. My problem is as follows: I have RGBA pixel data for a frame in a buffer that I need to display on the screen. My buffer is of type unsigned char. (I cannot change it to any other data type as the source code is too huge and not written by me.) Most of the links I found on the net say about how to "draw and display pixels" on the screen or how to "display pixels present in an array", but none of then say how to "display pixel data present in a buffer". I'm planning to use quartz 2D. All I need

How to draw a triangle with QUARTZ 2D?

此生再无相见时 提交于 2019-12-04 19:09:14
I'm developing an iPhone app with 3.1.3 SDK. I'm trying to draw a triangle with transparent fill an 1px black stroke with this code: CGContextMoveToPoint(ctx, position.X, position.Y - (size.height / 2)); CGContextAddLineToPoint(ctx, position.X - (size.width / 2), position.Y + (size.height / 2)); CGContextAddLineToPoint(ctx, position.X + (size.width / 2), position.Y + (size.height / 2)); CGContextFillPath(ctx); CGContextSetLineWidth(ctx, 1.0); CGContextStrokePath(ctx); CGContextSetFillColorWithColor(ctx, [[UIColor clearColor] CGColor]); But I get a black filled triangle. What am I doing wrong?

Problem adapting scale factor for iPad x2 compatibility mode

血红的双手。 提交于 2019-12-04 18:48:29
I wonder if anyone can help me with following. I have written a Quartz 2d ap and have used the following code to get the correct scale factor for each device : if ([UIScreen instancesRespondToSelector:@selector(scale)]) { return [[UIScreen mainScreen] scale]; } else { return 1.0; } I then multiply all values by this scale mulitplier in my code. The problem I have is that the app does not display propertly in x2 mode on the ipad - everything is two times too big. Can anybody help me ? Thanks, Martin Brad Larson The scale factor is related to the Retina displays on the newer iPhones and iPod

iPhone Quartz2D render expanding circle

余生颓废 提交于 2019-12-04 18:11:35
I'm curious as to the 'proper' method for achieving the following functionality using Quarts2D: I want to have a view, and to be able to add a circle at any coordinate. As soon as I add the circle it should expand at a predefined rate; I'd also like to repeat this process and have a number if these expanding circles. Think Missile Command: Generally, if I was writing this in C++ using SDL or some other graphics library I would: Have a class to represent an 'growing circle' Have a vector/array to hold pointers to all the 'growing circles' I create. All circles diameters would be increased each

Extract path information from an black&white bitmap image

不打扰是莪最后的温柔 提交于 2019-12-04 14:05:54
问题 It is not easy to draw a shape with Quartz 2D to depict an image as following. Is it possible to extract a CGPathRef information from a black&white bitmap image? The white part is actually transparent. Edit : What I want to achieve: I want to set the physicsBody of a SKSpriteNode with the same shape of the image bottle.png SKSpriteNode * myBottle = [SKSpriteNode spriteNodeWithImageNamed:@"bottle"]; . . . myBottle.physicsBody = [SKPhysicsBody bodyWithEdgeChainFromPath:path]; Her path is a

CoreAnimation, moving UIImageView with animating shadow in iOS 5 Xcode 4

烂漫一生 提交于 2019-12-04 13:42:38
问题 I am trying to add a (fake)3d like effect for an image (UIImageView moving from point A to B, during this movement I want at point C=(A+B)/2 for it to have the biggest shadow size (or larger shadow offset), so it looks like it is going up and down again. when I try to even change the shadow size, it is not animating. could you help me how to edit this code: NSValue *pointB = [NSValue valueWithCGPoint:CGPointMake(CGRectGetMinX(imageView.frame)+50, CGRectGetMinY(imageView.frame)+50)]; [self

How do I create a new image by drawing on top of an existing one using Quartz?

别等时光非礼了梦想. 提交于 2019-12-04 12:27:43
问题 i have a view with uiimageview i assign this uiimageview image by camera..now i want to do some drawing onto image....using coregraphics.i want to do something like this... select an area by touching and drawing line when line joins something like circle or any shape..i want to change that particular area in to something else for example change color there.turn that into grayscale.. till now i am able to draw line...here is an image of line drawn over a uiimage view... but i am unable to