Drawing a “Conical”/“Arcing” gradient in Objective-C (IOS) using Core Graphics?

The thread linked above suggests using pre-made images, but this isn't an option because the colors of the gradient should be settable, the view should be resizable and the fill of the progress bar isn't always 100% full obviously (which would be the state of the gradient as shown in the picture in the thread above) Not a problem! Use the very black-to-white image from the other question (or a bigger version if you need one), in the following fashion: Clip to whatever shape you want to draw the gradient in Fill with the color at the end of the gradient Use the black-to-white gradient image as a mask Fill with the color at the start of the gradient You can rotate the gradient by rotating the mask image This only supports the simplest case of a gradient with a color at each extreme end; it doesn't scale to three or more colors and doesn't support unusual gradient stop positioning.

The thread linked above suggests using pre-made images, but this isn't an option because the colors of the gradient should be settable, the view should be resizable and the fill of the progress bar isn't always 100% full obviously (which would be the state of the gradient as shown in the picture in the thread above). Not a problem! Use the very black-to-white image from the other question (or a bigger version if you need one), in the following fashion: Clip to whatever shape you want to draw the gradient in.

Fill with the color at the end of the gradient. Use the black-to-white gradient image as a mask. Fill with the color at the start of the gradient.

You can rotate the gradient by rotating the mask image. This only supports the simplest case of a gradient with a color at each extreme end; it doesn't scale to three or more colors and doesn't support unusual gradient stop positioning.

Going with this answer, solves exactly what I'm trying to do here, thanks! – Mordack Jun 26 at 23:32.

Looks to me like a job for a pixel shader. I remember seeing a Quartz Composer example that simulated a radar sweep, and that used a pixel shader to produce an effect like you're describing. Edit: Found it.

This shader was written by Peter Graffignino: kernel vec4 radarSweep(sampler image, __color color1,__color color2, float angle, vec4 rect) { vec4 val = sample(image, samplerCoord(image)); vec2 locCart = destCoord(); float theta, r, frac, angleDist; locCart. X = (locCart. X - rect.

Z/2.0) / (rect. Z/2.0); locCart. Y = (locCart.

Y - rect. W/2.0) / (rect. W/2.0); // locCart is now normalized theta = degrees(atan(locCart.

Y, locCart. X)); theta = (theta 1.0? Vec4(0.0, 0.0,0.0,0.0) : val; // constrain to circle return val; }.

Quartz Composer isn't available for IOS apps sadly, so this isn't an option. – Mordack Jun 26 at 18:51 2 @Mordack - Quartz Composer was the staging platform for this OpenGL shader, and is not necessary for it to run. It was just a nice way of doing rapid prototyping for a shader like this.

You should be able to implement an OpenGL ES 2.0 shader to do this, although it won't be easy. Peter's approach is probably what I'd prefer. – Brad Larson Jun 26 at 21:33 QC's not available, but pixel shaders are.

Use QC to try out your shader code. – NSResponder Jun 27 at 0:22.

FYI: here's also a good tutorial for creating a circular progress bar using Quartz drawing. turnedondigital.com/blog/quartz-tutorial....

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions