[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bevel filter



Hi Nathan,

>I am working on creating a square/rectangular bevel filter. The problem
>that i have encountered is getting the corners to go at an angle. If
>anyone could give me a hint, i would b most greatful. This is what i
>have so far:
>
>r:
>x<ctl(0)?r+ctl(1):r&& x>xmax-ctl(0)?r-ctl(0)/2-ctl(1):r&&
>y<ctl(0)?r+ctl(1)+ctl(0)+50:r&& y>ymax-ctl(0)?r-ctl(1):r
>
>g:
>x<ctl(0)?g+ctl(1):g&& x>xmax-ctl(0)?g-ctl(0)/2-ctl(1):g&&
>y<ctl(0)?g+ctl(1)+ctl(0)+50:g&& y>ymax-ctl(0)?g-ctl(1):g
>
>b:
>x<ctl(0)?b+ctl(1):b&& x>xmax-ctl(0)?b-ctl(0)/2-ctl(1):b&&
>y<ctl(0)?b+ctl(1)+ctl(0)+50:b&& y>ymax-ctl(0)?b-ctl(1):b
>
>slider(0): Bevel Width
>slider(1): Shadow and Highlight Depth

First of all, wenn algorithms in the channels only differ by r, g and b,
then replace them with "c". That way, you can experiment easily with copy
and paste:

r,g,b:
x<ctl(0)?c+ctl(1):
c&&x>xmax-ctl(0)?c-ctl(0)/2-ctl(1):
c&&y<ctl(0)?c+ctl(1)+ctl(0)+50:
c&& y>ymax-ctl(0)?c-ctl(1):c

I don't understand the "c &&"-part in the conditions. If you delete all,
nothing in the image happens:

r,g,b:
x<ctl(0)?c+ctl(1):
x>xmax-ctl(0)?c-ctl(0)/2-ctl(1):
y<ctl(0)?c+ctl(1)+ctl(0)+50:
y>ymax-ctl(0)?c-ctl(1):c

Now you have some problems with the corners. The first line of the code (top
button area) is actually not a rectangle, but a trapeze. The areas for the
trapeze are:

x < ctl(0)    AND    x<y     AND    x>Y-y

So, you need to include four boolean codes for the four corners:

r,g,b:
x<ctl(0) && x<y && x<Y-y ? c+ctl(1):
x>xmax-ctl(0) && y>X-x-1 && Y-y>X-x ? c-ctl(0)/2-ctl(1):
y<ctl(0) ? c+ctl(1)+ctl(0)+50:
y>ymax-ctl(0)  ? c-ctl(1):c

a: a

slider(0): Bevel Width
slider(1): Shadow and Highlight Depth

That's it. Study the code thouroughly to understand the technique.

Greetings from Germany,

Wernman