core-graphics

Making a pie chart using Core Graphics

泄露秘密 提交于 2019-12-20 09:48:57
问题 So far I have a filled in circle and that's about it. I'm trying to make a pie chart that represents the number of satisfied and unsatisfied customers and present it. I'm extremely new to CG and was wondering someone can crank out enough code to give me an idea or to guide me. Should I have the bottom circle represent the number of satisfied customers and then add another circle on top of it to show the unsatisfied customers? Am I approaching it in the right way? Here is my code so far.

draw embossed arc using core graphics

老子叫甜甜 提交于 2019-12-20 09:47:28
问题 I am trying to implement a custom slider as shown in figure below. what I have done so far looks something like this please help me out for drawing the arc with such effect. my code is as below, what I am doing is drawing the arc using CGContextAddArc with line width kLineWidth. - (void)drawThumbAtPoint:(CGPoint)sliderButtonCenterPoint inContext: (CGContextRef)context { UIGraphicsPushContext(context); CGContextBeginPath(context); CGContextMoveToPoint(context, sliderButtonCenterPoint.x,

Creating a large GIF with CGImageDestinationFinalize - running out of memory

对着背影说爱祢 提交于 2019-12-20 08:36:59
问题 I'm trying to fix a performance issue when creating GIFs with lots of frames. For example some GIFs could contain > 1200 frames. With my current code I run out of memory. I'm trying to figure out how to solve this; could this be done in batches? My first idea was if it was possible to append images together but I do not think there is a method for that or how GIFs are created by the ImageIO framework. It would be nice if there was a plural CGImageDestinationAddImages method but there isn't,

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

Core Graphics Performance on iOS

痴心易碎 提交于 2019-12-20 08:10:16
问题 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

Eraser the drawing in iOS

我们两清 提交于 2019-12-20 07:13:06
问题 I am working on a drawing app, I have a UIBezeirPath, with which I draw in touchesMoved, and convert it to CGPath and then draw on to CGlayer, Here is my code -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { self.currentPath = [[DrawingPath alloc] init]; if(m_eraseButtonClicked) { [self.currentPath setPathColor:[UIColor backgroundColor]]; } else { [self.currentPath setPathColor:self.lineColor]; } CGPathRef cgPath = self.currentPath.path.CGPath; mutablePath =

CGLayerRef in NSValue - when to call retain() or release()?

戏子无情 提交于 2019-12-20 05:42:20
问题 I am caching some graphics onto CGLayers and then storing them in NSValue objects using @encode (so as to store them in an array). I just wanted to make sure that I handle the retain/release correctly... I cache the graphics and store them in the array something like this: // Create an NSMutableArray "newCache" CGLayerRef drawingLayer = CGLayerCreateWithContext(context, bounds.size, NULL); CGContextRef drawingContext = CGLayerGetContext(drawingLayer); // Do some drawing... [newCache addObject

Pre-rendered Core Graphics animation doesn't animate smoothly & hogs memory

情到浓时终转凉″ 提交于 2019-12-20 04:24:06
问题 I am posting this question in response to one of the answers on my previous question here: Multiple CALayer masks causing performance issues So, now that I am attempting to go down the pre-rendered animation approach, I am still unable to get a smooth animation. Not only that, but when run on an actual device, the app crashes periodically due to memory issues. You can see the animation running here: http://cl.ly/e3Qu (It may not look so bad from the video, but focus on the edge of animation,

Clipping an image with a custom UIBezierPath

こ雲淡風輕ζ 提交于 2019-12-20 04:06:11
问题 I was wondering if someone could point me in the right direction with this problem. I have a user-created UIBezierPath with several points that have come about by user touches. I can get these to create shapes on a bog-standard UIView by using the [myPath fill]; function. What I would ideally like to do is to use the path to create a clipping mask for a UIImage - perhaps as a UiImageView ? I tried changing my UIView to a UIImageView and then changing the function to [myPath addClip]; but for

Draw a path with variable width in iOS

ぐ巨炮叔叔 提交于 2019-12-20 03:52:40
问题 I am working on a writing application, My writing is working fine, but what I want to implement is variable stroke width , so that the writing is very realistic and intuitive, as done by " BAMBOO " and " PENULTIMATE " application. Firstly I want to tell you what I have tried. 1) In iOS, their is no pressure detection, or velocity detection according to my research. For velocity detection, I have to use OPENGL. 2) Due to these limitations, I tried using the method given in this tutorial which