quartz-graphics

How to draw a triangle programmatically

懵懂的女人 提交于 2019-11-28 17:29:52
I have a triangle solver, I want a way to use the values I get from the answer to draw a triangle to the screen that matches it. If you subclass a UIView you can implement something like this in drawRect to draw a triangle: -(void)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextBeginPath(ctx); CGContextMoveToPoint (ctx, CGRectGetMinX(rect), CGRectGetMinY(rect)); // top left CGContextAddLineToPoint(ctx, CGRectGetMaxX(rect), CGRectGetMidY(rect)); // mid right CGContextAddLineToPoint(ctx, CGRectGetMinX(rect), CGRectGetMaxY(rect)); // bottom left

Drawing shadow with Quartz is slow on iPhone & iPad. Another way?

强颜欢笑 提交于 2019-11-28 17:13:37
问题 I was pretty excited when I found out just how easy it is to add shadows to my UIViews on the iPhone/iPad. Just add the framework in Xcode, add the import to the top of the file: #import <QuartzCore/QuartzCore.h> Then later: self.contentView.layer.shadowRadius = 3.0; self.contentView.layer.shadowOffset = CGSizeMake(-2.0, -3.0); self.contentView.layer.shadowOpacity = 0.5; self.contentView.layer.shadowColor = [UIColor blackColor].CGColor; While this does create a beautiful shadow in my app, it

What are the alternatives to Core-Plot for drawing graphs in iPhone SDK

别说谁变了你拦得住时间么 提交于 2019-11-28 16:34:19
Are there any alternatives to Core-Plot for drawing graphs in iPhone SDK? I am having hard time integrating core-plot in my app. Lot of issues. Can you please suggest some alternatives to core-plot? meetpd Some of the alternatives that I found were: http://sebkade.wordpress.com/2010/05/06/basic-graph-class-for-iphone/ http://www.rgraph.net/ http://www.ivisualization.com/ http://www.vvi.com/apps/vvidget http://cocoacontrols.com/platforms/ios/controls/tapku-graph (thanks Sudo for this link) http://www.shinobicontrols.com/ (latest addition) https://github.com/sweetynebhwani/deSimpleChart These

Quartz 2D drawRect method (iPhone)

只愿长相守 提交于 2019-11-28 16:22:50
I've got 4 different iPhone/Cocoa/Core Animation/Objective-C books in front of me, along with numerous sample code from the web. Yet somehow I still feel like I'm missing some fundamental understanding of how drawing works in Quartz 2D . Is drawRect() meant to simply be a hook in which to execute your drawing code? Or is this method supposed to also redraw regions that are "damaged", and need repainting? Can I just draw my stuff once and then it "sticks", or must I repaint the whole scene at any time via drawRect() ? Java's Graphics2D object works this way- you must draw your whole "image"

How to fill a path with gradient in drawRect:?

佐手、 提交于 2019-11-28 15:23:23
filling a path with a solid color is easy enough: CGPoint aPoint; for (id pointValue in points) { aPoint = [pointValue CGPointValue]; CGContextAddLineToPoint(context, aPoint.x, aPoint.y); } [[UIColor redColor] setFill]; [[UIColor blackColor] setStroke]; CGContextDrawPath(context, kCGPathFillStroke); I'd like to draw a gradient instead of solid red, but I am having trouble. I've tried the code listed in the Question/Answer: Gradients on UIView and UILabels On iPhone which is: CAGradientLayer *gradient = [CAGradientLayer layer]; [gradient setFrame:rect]; [gradient setColors:[NSArray

What's the difference between Quartz Core, Core Graphics and Quartz 2D?

浪子不回头ぞ 提交于 2019-11-28 15:20:44
I wonder if someone can distinguish precisely between these? For my understanding, Core Graphics is just a "Framework Package" which contains Quartz Core and Quartz 2D. But I'm not sure about if Quartz 2D actually is Quartz Core? Maybe someone can draw some lines there? What makes up the differences between these? When looking at the documentation, I see Quartz Core is listing up all the Core Animation stuff only. So Quartz Core == Core Animation? Brad Larson From the Quartz 2D Programming Guide : The Quartz 2D API is part of the Core Graphics framework, so you may see Quartz referred to as

3D Carousel effect on the iPad

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 14:59:38
问题 I am trying to implement a 3D Carousel on the iPad, consisting of UIViews, an effect like what is shown over here. I have gone through many similar questions on SO, but didn't find any staisfactory answers or no answers at all. I am trying to achieve the effect through modifying the coverflow animation but it just doesn't give that slick effect. Has anyone implemented this?(open for suggestions through quartz and openGL both) 回答1: No need to dive into Quartz or OpenGL, assuming you don't mind

undo redo issues with CGLayer

a 夏天 提交于 2019-11-28 13:08:00
I am working with unod redo operations on CgLayer, I have tried some code, but not able to get it working, dont know , where I am getting wrong, below is my code, which i have written this is my drawRect function - (void)drawRect:(CGRect)rect { m_backgroundImage = [UIImage imageNamed:@"bridge.jpg"]; CGPoint drawingTargetPoint = CGPointMake(0,0); [m_backgroundImage drawAtPoint:drawingTargetPoint]; switch(drawStep) { case DRAW: { CGContextRef context = UIGraphicsGetCurrentContext(); if(myLayerRef == nil) { myLayerRef = CGLayerCreateWithContext(context, self.bounds.size, NULL); }

layer.zPosition does not work with non-sibling UIViews

巧了我就是萌 提交于 2019-11-28 11:13:45
问题 I have a reasonably complex hierarchy of UIImageView s. Originally, I was carefully swapping the sibling order when one UIImageView moved in front of another. Then I found out about myUIImageView.layer.zPosition and switched to using this instead. Worked out much simpler. It even works almost all the time. I found out from this SO question that zPosition only works amongst sibling layers. Great! So I have two questions really: Is there any actual documentation about this? and, is there some

CGImageRef Memory leak

。_饼干妹妹 提交于 2019-11-28 10:20:12
I'm having a memory leak when using this custom method which returns a CGImageRef. I can't release "cgImage" properly because I have to return it. What chould I do ? - (CGImageRef)rectRoundedImageRef:(CGRect)rect radius:(int)radius { CGSize contextSize = CGSizeMake(rect.size.width, rect.size.height); CGFloat imageScale = (CGFloat)1.0; CGFloat width = contextSize.width; CGFloat height = contextSize.height; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, width * imageScale, height * imageScale, 8, 0, colorSpace,