core-graphics

Adding glowing effect to the circle

余生颓废 提交于 2019-12-04 09:23:49
I draw a circle in the drawRect method and fill it with a color. Now i need to add a glowing effect to the circle. When i click on a button, the circle needs to glow. How can i do this? Any help will be greatly appreciated! Thanks in advance!!! If you are using Quartz 2D, you can simply add a white shadow to the circle. See the Quartz 2D Programming Guide for Shadows Apple's Sample code for setting up a shadow taken from the link above: void MyDrawWithShadows (CGContextRef myContext, // 1 float wd, float ht); { CGSize myShadowOffset = CGSizeMake (-15, 20);// 2 float myColorValues[] = {1.0, 1.0

How to draw a gradient color wheel using CAGradientLayer?

柔情痞子 提交于 2019-12-04 08:21:51
问题 I got some reference from these links- What is the Algorithm behind a color wheel? Math behind the Colour Wheel Basic color schemes How to fill a bezier path with gradient color I have gone through the concept of "HSV colour space". But I want to draw a color wheel using RGB with the help of CAGradientLayer . Here is the code snippet of making a color wheel by using simple RGB color array and UIBezierPath - func drawColorWheel() { context?.saveGState() range = CGFloat(100.00 / CGFloat

ios: how to blur a image with CGPath?

流过昼夜 提交于 2019-12-04 07:59:37
I create a CGPath area as shown green circle. The CGPath area need to be clear, and the rest of image will be applied blurry or translucent effect, I can clip image inside CGPath with following code: UIGraphicsBeginImageContext(view.frame.size); CGContextAddPath(ctx, path); CGContextClip(ctx); [view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *clipImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(clipImage, nil, nil, nil); CGPathRelease(path); but I don't know how to apply blurry or translucent effect with CGPath

UIGraphicsGetCurrentContext vs UIGraphicsBeginImageContext/UIGraphicsEndImageContext

。_饼干妹妹 提交于 2019-12-04 07:58:32
问题 I am new to these parts of iOS API and here are some questions that are causing an infinite loop in my mind Why does ..BeginImageContext have a size but ..GetCurrentContext does not have a size? If ..GetCurrentContext does not have a size, where does it draw? What are the bounds? Why did they have to have two contexts, one for image and one for general graphics? Isn't an image context already a graphic context? What was the reason for the separation (I am trying to know what I don't know) 回答1

How to detect where NaN is passing to CoreGraphics API on Mac OS X 10.9

限于喜欢 提交于 2019-12-04 07:48:59
问题 I have very large graphic Mac app and now I receive a lot of the following messages in Console on 10.9 GM. <Error>: Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API. This is a serious error and contributes to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. I noticed that these messages appear in

Unexpected LineJoinStyle behavior when lines in path at 180 degrees

爷,独闯天下 提交于 2019-12-04 07:42:24
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 moveToPoint:CGPointMake(100, 120)]; [path addLineToPoint:CGPointMake(200, 120)]; [path addLineToPoint

drawing with clear color on UIView (cutting a hole) in static method

心已入冬 提交于 2019-12-04 07:18:11
I have an iPhone application and I need to implement the following method: +(UITextView *)textView:(UITextView *) withCuttedRect:(CGRect)r This method must cut (fill with [UIColor clearColor] ) the rect r from UITextView and return UITextView object. The user will see the view behind UITextView from the cutted holes. How can it be done? Joerg Simon When you would have something like: +(UITextView *)textView:(UITextView *)textView withCuttedRect:(CGRect)r { } you actually can simply access the textview's layer from core animation with textView.layer What you then can to is set a mask for

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

混江龙づ霸主 提交于 2019-12-04 06:31:43
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 / alphaValue); almostCorrectBlue = wrongBlue * (255 / alphaValue); But the problem is, that my

iOS CoreGraphics: Draw arc, determine arc angles from intersecting chord theorem

ε祈祈猫儿з 提交于 2019-12-04 06:24:18
I'm trying to figure out how to draw an arc in CoreGraphics. I understand which method calls to make and how to compute the angles in the following scenario. ---------- | | *--------* When the points are both in the bottom of the rect. However when two points are in other locations, I don't know how to calculate the correct angle. ---------* | | *--------- See bottom portion of my image. Ray Wenderlich has a great tutorial about creating arcs for only in the first mentioned point positions. // sample code for creating arc for path from bottom of rect CGMutablePathRef

How to reset to identity the “current transformation matrix” with some CGContext function?

浪子不回头ぞ 提交于 2019-12-04 06:21:50
I'm doing a series of translations and rotations on the CTM and at some point I need to reset it to identity before going further with transformations. I can't find any proper way to do it (obviously, there should have been a function named CGContextSetCTM or so) and since efficiency is the key, I don't want to use CGContextSaveGState/CGContextRestoreGState... Get current transformation matrix via CGContextGetCTM , invert it with CGAffineTransformInvert and multiply the current matrix by the inverted one (that's important!) with CGContextConcatCTM . CTM is now identity. Note that inverting the