FX expression for triangular Gradient
Posted: 2006-10-10T21:24:12-07:00
It is rare I ask for help of IM users, but here is one case.
Looking back the IM forum had a discussion of creating triangular gradients using programs outside IM. Well with the addition of variable assignments, the amount of complexity that can be encoded into -fx image expressions has increase significatally. As such it should not be able to do this using an FX expression. but I am stuck..
For example here is a gradient based on two points of color and the distance between them...
However i want to expand this to three points but I doesn't work. Can you find the problem?
This will be used in IM Examples
More Complex DIY Gradients
http://www.cit.gu.edu.au/~anthony/graph ... nt_complex
Looking back the IM forum had a discussion of creating triangular gradients using programs outside IM. Well with the addition of variable assignments, the amount of complexity that can be encoded into -fx image expressions has increase significatally. As such it should not be able to do this using an FX expression. but I am stuck..
For example here is a gradient based on two points of color and the distance between them...
Code: Select all
convert -size 100x100 xc: +size xc:red xc:yellow \
-fx 'ax=i/w-.8; ay=j/h-.1; ar=sqrt(ax*ax+ay*ay); \
bx=i/w-.1; by=j/h-.7; br=sqrt(bx*bx+by*by); \
u[1]*br/(ar+br) + u[2]*ar/(ar+br)' \
gradient_dist_ratio.gif
However i want to expand this to three points but I doesn't work. Can you find the problem?
Code: Select all
convert -size 100x100 xc: +size xc:red xc:blue xc:green1 \
-fx 'ax=i/w-.5; ay=j/h-.1; ar=sqrt(ax*ax+ay*ay);
bx=i/w-.1; by=j/h-.7; br=sqrt(bx*bx+by*by);
cx=i/w-.9; cy=j/h-.9; cr=sqrt(cx*cx+cy*cy);
rt=ar+br+cr; ra=1-ar/rt; rb=1-br/rt; rc=1-cr/rt;
zz=br*cr+ar*cr+ar*br;
u[1]*br*cr/zz + u[2]*ar*cr/zz + u[3]*ar*br/zz ' \
gradient_triangular.gif
This will be used in IM Examples
More Complex DIY Gradients
http://www.cit.gu.edu.au/~anthony/graph ... nt_complex