quartz-2d

Problem : iPhone graphics go mad !

Helloo! I faced a really stranged problem recently. I am doing a timetable organizer, and I draw each event in a DayViewController with Quarz 2D, then I add a "glass effect" picture (PNG). But randomly, as I switch between days, the layout go really bad. Here is a link to see the good appearance and below the bad one : http://toucotton...

Using the contents of an array to set individual pixels in a Quartz bitmap context

I have an array that contains the RGB colour values for each pixel in a 320 x 180 display. I would like to be able to set individual pixel values in the a bitmap context of the same size offscreen then display the bitmap context in a view. It appears that I have to create 1x1 rects and either put a stroke on them or a line of length 1 ...

drawing different quartz 2d

Hello, I'm trying to make a small application or demo thats a tab bar application. Each bar item loads in a new view. I've created a quartzView class that is called on by the controller: - (void)viewDidLoad { quartzView *drawingView = [[quartzView alloc] initWithFrame:CGRectMake(0,0,320,480)]; [self.view addSubview:drawingView...

Do I have a memory management problem in here?

Something must be wrong with this code right here: + (UIImage*)captureView:(UIView *)theView { UIGraphicsBeginImageContext(theView.frame.size); [theView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; ...

Is this a good way to do a game loop for an iPhone game?

Hi all, I'm new to iPhone dev, but trying to build a 2D game. I was following a book, but the game loop it created basically said: function gameLoop update() render() sleep(1/30th second) gameLoop The reasoning was that this would run at 30fps. However, this seemed a little mental, because if my frame took 1/30th seco...

How to set up a user Quartz2D coordinate system with scaling that avoids fuzzy drawing?

This topic has been scratched once or twice, but I am still puzzled. And Google was not friendly either. Since Quartz allows for arbitrary coordinate systems using affine transforms, I want to be able to draw things such as floorplans using real-life coordinate, e.g. feet. So basically, for the sake of an example, I want to scale the v...

Drawing triangle/arrow on a line with CGContext

Hi, I am using the framework of route-me for working with locations. In this code the path between two markers(points) will be drawn as a line. My Question: "What code should I add if I want to add an arrow in the middle(or top) of the line, so that it points the direction" Thanks - (void)drawInContext:(CGContextRef)theContext { ...

Freehand drawing with Quartz 2D

I am trying to develop a simple freehand-drawing app for red-marking some of my images. Below is a method that is called from within the drawRect. I want to ask if there is a way to avoid adding the path every time before the path is redrawn? Also, the way the draw method is set up, the drawing gets a bit slow and choppy after a few se...

How to draw an animatable ruler with Quartz2D?

I'd like to draw the lines of a simple ruler with Quartz2D, just for practice. Since I have no idea about doing vector graphics programmatically on the iPhone, maybe someone can point me to a good tutorial to get started? ...

Create a table of contents from a pdf file

I'm using quartz to display pdf content, and I need to create a table of contents to navigate through the pdf. From reading Apple's documentation I think I am supposed to use CGPDFDocumentGetCatalog, but I can't find any examples on how to use this anywhere. Any ideas? ...

Does Quartz2D test intersection of rect by line before drawing it.

I'm drawing a big scheme that consist of a lot of lines. I do it in the drawRect: method of UIView. The scheme is larger than the layer of view and I check each line and draw it only if it intersects the visible rect. But at one moment I thought, should I do this? Maybe Quartz is already doing this test? So the question is: When I use f...

How to draw a drop shadow AND gradient with quartz2d?

Hello! I've a custom shape drawing using coregraphics and i want to add a drop shadow and a gradient to it also. I've been trying and searching a lot of informations on how to combine and do this, but i can't get it to work. I'm able to draw only one either. Anyone doing this already or know how to do this? Thank you. ...

Quartz 2D or OpenGL ES? Pros and cons in the long term, possibility of migration to other platforms.

Hi all! I'm having a hard time deciding whether to go with Quartz2D or OpenGL for an iPad game. It will be 2D mostly, but effect-intense (simultaneous lighting effects for 10-30 objects, 10-20 simultaneous animations on the screen). So far, assuming i'm equally dumb in both technologies and have to learn them from the ground, i came to ...

Removing the image from an IKImageView

I have an IKImageView that is coming up effectively un-initialized. This is happening effectively in an error-state (The user is unregistered) so I haven't had a chance to put an image in it yet. In 10.6, this comes up fine, with a black rectangle. In 10.5, however, it comes up with garbage. some rectangles of noise, some rectangles of...

Simulating graphing paper on iPhone

I need to implement 'graphing paper' in an iPhone app. The user should be presented with a grid. They user can touch individual squares to turn them on, or if they're already on, off.The user can pinch to zoom and scroll around the paper as well.. So far I'm thinking Quartz 2D + UIScrollView is the way to do this but these are both are...

Why are all my masked views unmasked in my view snapshot?

I'm taking a snapshot of an view. This view has got some subviews which have layer masks applied to them. For some reason, those masks take no effect in the snapshot and the masked parts are completely visible. UIGraphicsBeginImageContext(theView.frame.size); [theView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *newIma...

Is there a way to make a CGPath grow by x Pixels?

I'm building a custom UIView, which draws its own content in a drawRect: Method. I want to stroke a CGPath with a color, and then grow this selection 1px and stroke with another color. Has somebody worked out a method to do this quite easily? ...

CGContextSetRBStrokeColor to replace, not add, for alpha?

I use CGContexts to allow the user to draw in my application, here's an example: CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), size); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(),r,g,b,a); I want the user to have an "eraser" tool that a...

How do I set the current point in a CG graphics context?

When running the code below in the iphone simulator I get the error : CGContextClosePath: no current point. Why is the current point not being set? Or is the context not set to the correct state? CGContextBeginPath(ctx); CGMutablePathRef pathHolder; pathHolder = CGPathCreateMutable(); //move to point for the initial point ...

CGPath and Quartz 2D

I want to create a triangle using Quartz 2D functions. The 3 edges of the triangle should be in different colors. I am able to create the triangle but not able to set the color of each edge or subpath separately. Any suggestions or sample code are much appreciated. ...