Try:
const float PI = 3.14159265359;
const float TWOPI = 6.2831853071796;
kernel vec4 angleGrad(sampler Image, __color Color0, __color Color1)
{
// Normalized pixel coords (0 > 1 range)
vec2 xy = samplerCoord(Image) / samplerSize(Image);
// Coords offset so 0,0 is at center
xy = xy * 2.0 - 1.0;
// Angle between centre and current pixel
float phi = atan(xy.y, xy.x);
// Create mix level var
float mixLvl = (phi + PI); // Scale to 0 > TWOPI
mixLvl /= TWOPI; // Divide to 0 > 1
(normalize)
// Mix colors0 and 1 and return pixel
return mix(Color0, Color1, mixLvl);
}
in a CIFilter patch.
That's a simple 2-colour version. You'd have to do some clever maths
to create a version with more colours.
Hope this helps,
a|x
http://machinesdontcare.wordpress.com
On 18 Feb 2009, at 13:06, Luigi Castelli wrote:
Let's imagine a circle and let's say that the beginning of the
circle is the topmost point located at an angle of 0 degrees. Then
the rightmost point would be located at an angle of 90 degrees. The
bottommost point at an angle of 180 degrees and the leftmost point
at 270 degrees.
I want to be able to create a gradient whose color changes
according to the angle. So for instance at 0 degrees is white and
at 90 degrees black, and so on and so forth...
I hope I made myself clear.
I think photoshop refers to these kind of gradients as angular
gradients.
Ideas?
Thanks.
- Luigi
--- On Wed, 2/18/09, Alex Drinkwater <[email protected]> wrote:
From: Alex Drinkwater <[email protected]>
Subject: Re: Gradients along a circular path
To: [email protected]
Date: Wednesday, February 18, 2009, 2:53 AM
Do you mean a gradient that would look like a torus, or a
tube bent around into a ring?
If so, you could use the distance() function, and two
smoothstep()s.
a|x
On 18 Feb 2009, at 09:50, Luigi Castelli wrote:
Yes, of course...
I am very familiar with routines for both creating
axial and radial gradients. My question is about creating
gradients that follow arbitrary paths. Specifically for my
case, I need an axial gradient around a circular path.
I am sure I am not the first one with this problem...
Any solutions?
Thanks
- Luigi
--- On Tue, 2/17/09, Brian Bucknam
<[email protected]> wrote:
From: Brian Bucknam <[email protected]>
Subject: Re: Gradients along a circular path
To: "Quartz-Dev List"
<[email protected]>
Cc: [email protected]
Date: Tuesday, February 17, 2009, 1:37 PM
On Feb 17, 2009, at 1:19 PM, Luigi Castelli wrote:
is there a way in Quartz to draw a linear
gradient
along a path other than straight? Along a circular
path, for
instance...
Have you looked at CGShadingCreateRadial() ? That
answers
the circular issue, now if only there were a way
to do it
along an arbitrary path...
Cheers,
Brian
_______________________________________________
Do not post admin requests to the list. They will be
ignored.
Quartz-dev mailing list
([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/the_voder%
40yahoo.co.uk
This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/the_voder%
40yahoo.co.uk
This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [email protected]