iOS 5 and interpolatedColorAtLocation. Get the color in a gradient at a specific location - ios5

How can I get the color in a gradient at a specific position in iOS 5?
I have a vertical bar with a gradient from red to green and on the left side is a triangle showing the position in the bar. How can I fill the triangle with the color of the bar at that position?
I think in Mac OS X it's "interpolatedColorAtLocation" but how about iOS 5?
Thank you for help.

There's no API for this in iOS. You'll have to do the gradient interpolation yourself, or draw your gradient into a CGBitmapContext and then find the pixel value in the bitmap's raw data.

Related

danielgindi/charts: How get round corners for Graph?

I am using iOS Charts (https://github.com/danielgindi/Charts) for line chart.
I gave background color to grid (Light Gray) as don’t want to include axis values.
lineChartView.gridBackgroundColor = .lightGray
Is there any way i can make corner of the graph rounded. not able to give corner radius for grid background color.

Iphone App Color to black&White Image RGB Value

Currently i am working on Iphone app similar to http://itunes.apple.com/us/app/color-splash-free/id385504846?mt=8 in which we can make some or full portion of pic as black and white.
Please check the attach image for more detail.
I just want to know that how i can start it.I am familiar with paint app.Is this any rgb Value of any color or Its gray scale overlapping of an image with actual image at background or hide some portion of actual image and show grayscale image in that part.
Please share any code if you have that.
Thank you
Can't offer a concrete answer but a general approach from doing something similar.
What you have in 32 bit image is 4 channels of pixel information: red pixels, green pixels, blue pixels and alpha value for each pixel.
A gray image as you know from using any paint program is when all three colour components red, green and blue have equal intensity value.
E.g.
rgb value of (0.5,0.5,0.5) would be halfway between black and white.
What I can suggest is you looking into finding where the user tap the screen, take rectangular sample of pixels from the touch point into memory loop through all the sample pixels and set their red, green and blue value to be equal, then redraw the newly modified image onto the view again.
If you want to quickly convert an entire image to grayscale, you can use GPUImageFramework by Brad Larson? (apologies if I misspelled your name Brad :P).
You can use his GrayScaleFilter class to generate a grayscale image.

Tween between radial gradients

I am new to Objective C for iOS programming, so please be nice :-).
I have an app in Android (Java) app that I want to port to iOS. In Android I have 3 radial gradient backgrounds (red-black, green-black, blue-black) defined in an XML shape and I can easily transform between the 3 in a loops animation.
I want to do the same in iOS.
So far I have read about:
CAGradientLayer,
CAGradient,
CGGradient
..and I'm utterly confused.
Can somebody explain what and how is the best way to animate between 3 radial gradients, and does this need to be coded or using PNG's ?
Thanks
I did eventually solve this, using the built in animation function to change the View's background colour from Rad, to Yellow, to Green.
I then made a PNG which was a radial gradient from center alpha 0 to outer black alpha 100.

Change color of the iPhone screen

I need to change the color of the iPhone screen when i touch on it. The only thing i need to do is to change the color of the area where i am touching. if i am placing a star on the screen as touch then only that area color will be changed.
Any idea about this?
Take a look at some of the Graphics and Animation iPhone SDK Samples - there are samples there that show how to paint with different colours and other samples of how to use user input.

Coloring Image in iPhone SDK

i am developing a iphone app. i have a background image lets say an airplane with black color out lines and from color palette user can pick a color and fill the region of airplane....any help, code , suggestion will highly be appriciated
A simple fill algorithm should do. just expand from the point you are on until you meet region end pixels
see http://en.wikipedia.org/wiki/Flood_fill you can also try googling for Boundary Fill algorithm
My first though was to have a UIView and a mask image on top of that with the plane but this only works in certain situations. If the shape of the plane does not change you could also change the color and then "fill" the plan in during the drawRect using functions like CGContextAddArc and CGContextAddRect.