Draw a gradient without banding (dithered) on iOS - ios

Is there a way to dynamically draw a dithered gradient on iOS? I'm currently using CGContextDrawLinearGradient, but it produces a noticeable banding effect.

Related

Generate radial gradient based on blurred image

I'm trying to find a way to calculate the gradient of a given image with a blurred overlay with a specific opacity on top. Here is an example :
This is the settings for the black overlay, background blur is set to 515px and color is black with 40% of opacity.
This is the based image (without the transparent black overlay)
And this is how it looks when both are layered, as you can see it looks like a gradient. What I'm trying to achieve is a similar gradient with similar color but I'm not sure which colors are used. I know I need to extract some colors from the based picture and used them to create multiple layers but because I don't understand what the blur exactly does I'm not sure what to do.

Create custom shape using Bezier Curve in iOS

I have one requirement to show the a shape (like Home or Car etc) and depending upon the percentage of the condition will be filled with animation
I was trying with image but when I googled, I found this can be achieved by drawing image using Bezier curve.
So this is the image I am trying to draw and there are other images too.
So here are my two questions :
Can I achieve this using UIImage directly.
If not then how can i draw bezier
curve for such images. How will I calculate the points.

"shape burst" stroke in iOS Core Graphics

Is there a way to create the following effect in Core Graphics by stroking a CGPathRef?
If it is possible, would it be more efficient to draw with Core Graphics vs. simply drawing a radial ellipse CGImageRef a whole bunch of times along the path?
Edit: to clarify: I want the central part of the stroke to be 100% opacity, and the edges to fade out from 100% opacity to 0% opacity.
Edit 2: also, I intend to use this drawing in an MKOverlayView to highlight a user's path... so not sure if a blur filter would be performant enough.
A round-capped, thick path with a shadow on it is probably the best solution for you. That would involve:
CGContextSetLineWidth()
CGContextSetLineCap()
CGContextSetShadowWithColor()
You'd want a zero offset shadow, and you'll need to experiment with the radius and blur parameters to get the effect you're after.

Cocoa CoreGraphics: How to fill multiple shapes with a gradient

I have logo text drawn as shapes (closed CGBezierPaths) that I want to fill with a gradient.(Light at the top, moving to dark at the bottom) How can I fill each shape with gradient such that the gradient is the same color for each shape.
The problem is drawing the gradient for each shape, if the letters are different height then the gradient has a different ramp since the distance is smaller. Hope that makes sense.
So basically I want draw a single gradient down the rect and use all the shapes as a clipping mask. Is this possible?
For gradient drawing - take a look at this project:
https://github.com/wczekalski/CDPieMenu
It creates gradient using two colors programmatically.

blend overlapping triangles in opengl

I'm building a thick line from triangles. The problem i'm having is that when the curve is semi transparent and some triangles overlap i get the effect in the picture. I would like for the triangles alphas to not get added.
I'm using this blend function:
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_CONSTANT_ALPHA);
You may render the curve to separate render target with full opacity and then draw that target with custom alpha. Otherwise you should avoid overlapping.
you can use stencil test for blocking the drawing of already drawn fragments (which prevent blending from the first place)

Resources