core-graphics

CAGradientLayer and scrollViewTexturedBackgroundColor

我怕爱的太早我们不能终老 提交于 2019-12-22 00:44:17
问题 I'm trying to use CAGradientLayer to fade foreground controls against the background textured view. So in a nutshell, I have a view with the bg color as scrollViewTexturedBackgroundColor. I have a view on top of that, whose contents I'd like to fade at the border into the background view's color. CAGradientLayer* gradient = [CAGradientLayer layer]; gradient.frame = self->scrollableCanvas.bounds; gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor scrollViewTexturedBackgroundColor]

What is the proper way to make it so core graphics does not lag?

痞子三分冷 提交于 2019-12-22 00:35:32
问题 I use UIBezierPath for finger painting (my app). I create it using path = [UIBezierPath bezier path]; . It constantly lags on the iPad (and calling it from within drawrect did not change anything). I have been working on this for hours on end and have found no solution, just lag. Would somebody be so kind to help me please? Also, I am using a NSTimer to call the function. That is the old way my app will work so please help me fix this lagggg!!!!! 回答1: Since none of your questions contains

Draw a shadow which is hidden under the semi-transparent view?

廉价感情. 提交于 2019-12-21 21:43:06
问题 I have a semi-transparent view with a drop shadow. I mocked it up in photoshop, which doesn't draw the shadow under the object. Then I made it in xcode, but it obviously does draw the shadow underneath. I was wondering if there's a way to avoid this. In other words - have the shadow only appear outside of the shape? 回答1: You probably want to set the rasterized property of the layer to YES, which will composite the shadow before other effects such as opacity are applied to the view. Note

CoreGraphics: Using finger strokes to erase part of image?

巧了我就是萌 提交于 2019-12-21 20:37:58
问题 I'm working on drawing code to erase part of an image. I'm not an expert on CoreGraphics and could use some help. This routine works fine, however, when moving fast, it loses touches (Not very smooth). Can this routine be modified to make CGContextClearRect smoother? Is there a better, faster way to do this? -(void)drawRect:(CGRect)rect { if (!myDrawing) { // touchpoints stored here myDrawing = [[NSMutableArray alloc] initWithCapacity:0]; } UIGraphicsBeginImageContext(frontImage.frame.size);

CGContextDrawImage draws large images very blurry

北战南征 提交于 2019-12-21 20:15:39
问题 I'm trying to make an object that can draw a portion of a large (say 2048 x 1537) image using CGContextDrawImage(…). It works just fine, except that it is extremely blurry. I'm using a "drawingController" which overrides drawLayer:inContext: like this -(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{ CGImageRef drawImage = CGImageRetain(imageToDraw); if(drawImage) { CGRect drawRect = CGRectMake(0, 0, 1024, 748);//Just hard coded to my window size for now.

Horizontal Flip of a frame in Objective-C

旧时模样 提交于 2019-12-21 19:28:05
问题 I am trying to create a filter for my program (which streams a webcam) which makes the frame flip horizontally, making the webcam act like a mirror. However, while it compiles and runs, the filter does not seem to have any effect on it. Here is the code: CIImage *resultImage = image; CIFilter *flipFilter = [CIFilter filterWithName:@"CIAffineTransform"]; [flipFilter setValue:resultImage forKey:@"inputTransform"]; NSAffineTransform* flipTransform = [NSAffineTransform transform]; [flipTransform

Horizontal Flip of a frame in Objective-C

跟風遠走 提交于 2019-12-21 19:27:14
问题 I am trying to create a filter for my program (which streams a webcam) which makes the frame flip horizontally, making the webcam act like a mirror. However, while it compiles and runs, the filter does not seem to have any effect on it. Here is the code: CIImage *resultImage = image; CIFilter *flipFilter = [CIFilter filterWithName:@"CIAffineTransform"]; [flipFilter setValue:resultImage forKey:@"inputTransform"]; NSAffineTransform* flipTransform = [NSAffineTransform transform]; [flipTransform

Framebuffer/Color Buffer?

不羁岁月 提交于 2019-12-21 17:52:29
问题 Can someone point out to me if both of them are the same? I mean I have been reading info about it and this redbook here says "The color buffer itself can consist of several subbuffers. The framebuffer on a system comprises all of these buffers" here Is framebuffer then like a virtual buffer consisting of all the actual buffers ?(like depth/stencil etc) 回答1: The framebuffer contains (often) the depth, stencil, color, and accumulation buffers. The color buffers are the most important part, but

Sine CAShapeLayer as a mask of CALayer

一笑奈何 提交于 2019-12-21 16:51:15
问题 I'm trying to implement the next curious thing: I have a few dots and I'd like to link them with sine waves Next method returns the array of dots for making plot: - (NSArray *)plotPointsBetweenPoint:(CGPoint)pointA andPoint:(CGPoint)pointB { double H = fabs(pointB.y - pointA.y); double L = fabs(pointB.x - pointA.x); NSInteger granularity = 40; NSMutableArray *array = [NSMutableArray arrayWithCapacity:granularity + 1]; for (int i = 0; i <= granularity; ++i) { CGFloat x = M_PI*(float)i/

Unexpected LineJoinStyle behavior when lines in path at 180 degrees

拜拜、爱过 提交于 2019-12-21 14:13:53
问题 I'm getting a clipped LineJoin in a UIBezierPath when one line comes back exactly over the previous line. If I adjust the second line by one pixel, the LineJoin behaves as expected. Here's the code: UIBezierPath *path = [UIBezierPath bezierPath]; [path setLineWidth:10.0f]; [path setLineCapStyle:kCGLineCapRound]; [path setLineJoinStyle:kCGLineJoinRound]; [path moveToPoint:CGPointMake(100, 100)]; [path addLineToPoint:CGPointMake(200, 100)]; [path addLineToPoint:CGPointMake(150, 100)]; [path