quartz-2d

How to get the real RGBA or ARGB color values without premultiplied alpha?

早过忘川 提交于 2019-12-21 12:31:32
问题 I'm creating an bitmap context using CGBitmapContextCreate with the kCGImageAlphaPremultipliedFirst option. I made a 5 x 5 test image with some major colors (pure red, green, blue, white, black), some mixed colors (i.e. purple) combined with some alpha variations. Every time when the alpha component is not 255, the color value is wrong. I found that I could re-calculate the color when I do something like: almostCorrectRed = wrongRed * (255 / alphaValue); almostCorrectGreen = wrongGreen * (255

Quartz 2d / Core Graphics: What is the right way to draw some text?

笑着哭i 提交于 2019-12-21 12:24:25
问题 I've been at this for awhile, it seems that there's many ways to go about this in quartz 2d: 1) Draw text using core graphics methods... CGContextSelectFont CGContextSetRGBFillColor CGContextShowTextAtPoint and on and on, which is horribly low level. 2) using NSString drawAtPoint (so far the method I like) NSString* text = @"Hello"; [text drawAtPoint:point withFont:font]; 3) using UILabel I've read this somewhere but not too sure if this is possible. but I'm thinking that instantiating a

Combining Intersecting CGPaths on iOS

冷暖自知 提交于 2019-12-21 05:09:06
问题 I have a problem in an app I'm working on. Say I have two CGPaths that are fairly complex and I add them both to a CGMutablePath (thus combining them). Well, where the two paths intersect there will be points inside of each other. I want to eliminate those inside points and essentially draw the outside or outline of the path. I am having difficulty figuring out how I would go about this. Edit: Here's an example of what I am talking about. The blue and red boxes represent points along the

CGContextClipToMask returning blank image

佐手、 提交于 2019-12-21 04:12:08
问题 I'm new to Quartz. I have 2 images, a background, and a mask with cutout shape that I want to lay over the background in order to cut out a section. The resulting image should be the shape of the cutout. This is my mask (the shape in the middle is 0 alpha): And this is my code: UIView *canvas = [[[sender superview] subviews] objectAtIndex:0]; UIGraphicsBeginImageContext(canvas.bounds.size); CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef cgContext =

Drawing Game Center like tableview cells

半城伤御伤魂 提交于 2019-12-21 02:42:10
问题 I've now added a bounty which will be awarded to anyone who can take the three images below and produce a working implementation of a UITableView that mimicks the look and feel of the one found in Game Center on the Games tab. The implementation must use a non-grouped tableview but demostrate each of the four cell variants (top, middle, bottom and single) Can anyone shed any light on how Apple achieve the Game Center tableview cells which appear on the Games tab? I'm specifically referring to

How to create a CGLayer from a UIView for off-screen drawing

和自甴很熟 提交于 2019-12-21 02:20:29
问题 I have read what I believe to be the relevant parts of the Quartz 2D Programming Guide, but cannot find an answer to the following (they don't seem to talk a lot about iOS in the document): My application displays a drawing in a UIView . Every now and then I have to update the drawing in some way, e.g. change the fill colour of one of the shapes (I keep CGPathRefs to the important shapes to be able to redraw them with a different fill colour later). As described in the Section "Drawing With a

How to add a transparent gradient mask to a context

你。 提交于 2019-12-20 17:26:20
问题 I am using quartz 2d to draw a pie chart. I use layer to draw a reflection of the pie chart on the bottom. I would like to add a transparent alpha gradient to the reflection to make the it more and more transparent until it gets invisible. Someone has an idea ? @EDIT : more details My pie chart is in a CGLayerRef. I first draw this layer to the CGContextRef. Then I do a CGContextTranslateCTM(context, 0, rect.size.height); CGContextScaleCTM(context, 1.0, -1.0); To be upside down. Then i draw

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

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 14:42:02
问题 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 this list. (I've read several topics here, on SO, with names like "Quartz or OpenGL", but i'm still left with some questions) Quartz : Better time-to-market, because

Quartz 2D vs OpenGL ES Learning Curve

隐身守侯 提交于 2019-12-20 14:09:33
问题 I have been developing iPhone Applications for a couple of months. I would like to know your views about the Quartz vs OpenGL ES 1.x or 2.0 learning curve. You can tell your perspective. My Questions are *I am a wannabe game developer, So is it a good idea to first develop in quartz , then move on to OpenGL ES or does it not make an difference *Can you please tell your experiences when you were having the similar question Thanks :) 回答1: Quartz 2D is not applicable for game development IMHO.

Core Graphics Performance on iOS

旧街凉风 提交于 2019-12-20 08:12:28
问题 Summary I'm working on a fairly straightforward 2D tower defense game for iOS. So far, I've been using Core Graphics exclusively to handle rendering. There are no image files in the app at all (yet). I've been experiencing some significant performance issues doing relatively simple drawing, and I'm looking for ideas as to how I can fix this, short of moving to OpenGL. Game Setup At a high level, I have a Board class, which is a subclass of UIView , to represent the game board. All other