quartz-graphics

Comparing colors in Objective-C

萝らか妹 提交于 2019-12-01 04:09:18
I'm trying to determine if two colors are equivalent, using code written in Objective-C. I'm using this snippet of code to determine if the two colors are equivalent (currently for debugging purposes) NSLog(@"currentColor is %@", currentColor); NSLog(@"Adjacent Color is %@",[[buttonArray objectAtIndex:1] backgroundColor]); NSLog(@"%i",[[buttonArray objectAtIndex:1] backgroundColor]==currentColor); My console is showing 2009-10-20 00:27:10.814 colorGame[13588:207] currentColor is kCGColorSpaceModelRGB 0 0 1 1 2009-10-20 00:27:10.815 colorGame[13588:207] Adjacent Color is kCGColorSpaceModelRGB 0

How do you load a local jpeg or png image file into an iPhone app?

試著忘記壹切 提交于 2019-12-01 02:30:29
Or I should ask why is it so difficult for me? The answer is probably that I'm new to iPhone development and I'm trying to ditch my old methods and step into the new platform of the future. From start to finish, I have a few questions about this process... If I create a .png image, where does it go in my project's directory (i.e. my computer's hard drive)? Can I put it anywhere on my hard drive and Xcode will copy it in the right place when I load it into Xcode? Once it exists on my hard drive somewhere, how do I add it to my Xcode project? Can I just drag the file into any folder in the

What should I learn: Quartz or OpenGL ES? [closed]

回眸只為那壹抹淺笑 提交于 2019-12-01 02:12:20
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I'm learning to program for the iPhone. I'm trying to figure out how to do some really cool custom view animations. What should I

Make a Vortex in Box2D

泪湿孤枕 提交于 2019-12-01 00:59:45
I'm trying to make a spiral vortex in Box2D on C++ / Objective C by applying forces. What I would like to realize is a vortex that pushes the bodies from a point, or that attract them. I guess I'll have to apply more than one force. My entry point in this problem is : I think I have to apply 3 forces : - An impulse to attract or repulse the body from the center. - An impulse to make it move laterally on a spiral, but... how ? - A torque to rotate the body itself if the impulse don't do it for me. I once did a rotating platform by making a circular sensor which applied a tangential speed change

Core Graphics, how to draw a Rectangle with an ellipse transparency hole?

此生再无相见时 提交于 2019-11-30 23:25:59
I am trying to draw a 320x480 rectangle that is hollowed by a ellipse. Imagine drawing a filled rectangle, over the rectangle an filled ellipse, and remove the ellipse from the rectangle, leaving a transparent hole. - (void)drawRect:(CGRect)rect { // Drawing code. CGContextRef context = UIGraphicsGetCurrentContext(); // Set color to red CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0); // Add rectange CGContextAddRect(context, rect); // Fill rectange CGContextFillRect(context, rect); // Create a elipse to be removed from rectange CGPathRef circlePath = CGPathCreateMutable();

How do I programmatically provide a glossy look to UIButtons?

馋奶兔 提交于 2019-11-30 23:14:54
I would like to add 3D or glossy look to some iPhone UIButtons, but do so without the use of PNGs or stretchable images. I have a lot of buttons of varying shapes and sizes with lots of colors which are generated on the fly, so prerendered images are not feasible in my case. How would you go about drawing the gloss on these buttons programmatically? Brad Larson In this answer , I provide some code for drawing a gloss gradient over a UIView, but Mirko's answer to that same question shows a more performant way of doing this. I created a more elaborate 3-D button style, with gloss and shadowing,

How do you load a local jpeg or png image file into an iPhone app?

我与影子孤独终老i 提交于 2019-11-30 22:05:31
问题 Or I should ask why is it so difficult for me? The answer is probably that I'm new to iPhone development and I'm trying to ditch my old methods and step into the new platform of the future. From start to finish, I have a few questions about this process... If I create a .png image, where does it go in my project's directory (i.e. my computer's hard drive)? Can I put it anywhere on my hard drive and Xcode will copy it in the right place when I load it into Xcode? Once it exists on my hard

Make a Vortex in Box2D

末鹿安然 提交于 2019-11-30 19:37:03
问题 I'm trying to make a spiral vortex in Box2D on C++ / Objective C by applying forces. What I would like to realize is a vortex that pushes the bodies from a point, or that attract them. I guess I'll have to apply more than one force. My entry point in this problem is : I think I have to apply 3 forces : - An impulse to attract or repulse the body from the center. - An impulse to make it move laterally on a spiral, but... how ? - A torque to rotate the body itself if the impulse don't do it for

Core Graphics, how to draw a Rectangle with an ellipse transparency hole?

可紊 提交于 2019-11-30 18:52:25
问题 I am trying to draw a 320x480 rectangle that is hollowed by a ellipse. Imagine drawing a filled rectangle, over the rectangle an filled ellipse, and remove the ellipse from the rectangle, leaving a transparent hole. - (void)drawRect:(CGRect)rect { // Drawing code. CGContextRef context = UIGraphicsGetCurrentContext(); // Set color to red CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0); // Add rectange CGContextAddRect(context, rect); // Fill rectange CGContextFillRect(context, rect); //

How do I programmatically provide a glossy look to UIButtons?

淺唱寂寞╮ 提交于 2019-11-30 18:04:40
问题 I would like to add 3D or glossy look to some iPhone UIButtons, but do so without the use of PNGs or stretchable images. I have a lot of buttons of varying shapes and sizes with lots of colors which are generated on the fly, so prerendered images are not feasible in my case. How would you go about drawing the gloss on these buttons programmatically? 回答1: In this answer, I provide some code for drawing a gloss gradient over a UIView, but Mirko's answer to that same question shows a more