Older Newer
Sat, 05 Apr 2003 20:58:58 . . . . (Pete)?


Changes by last author:

Added:
= c2d =

== Syntax ==

:int c2d(int x, int y)

== Arguments ==

:x

::An integer pixel x-coordinate.

:y

::An integer pixel y-coordinate.

== Return ==

:An integer in the range -511 to 512.

== Description ==

:Pixels are usually addressed by their cartesian coordinates [x,y], but FilterMeister also allows the use of polar coordinates, and provides a set of functions for conversion between the two systems. Polar coordinates are expressed as [d,m], where 'd' represents the 'direction' to the pixel from the origin [0,0], and 'm' is the 'magnitude' of the distance from the origin. The c2d() function returns the polar coordinate direction 'd' for the pixel at [x,y], relative to the top left corner of the image. A 'd' value of 0 represents the direction to the right along the x-axis (ie y=0); a value of 256 represents the direction downward along the y-axis (ie x=0); a value of 512 represents the direction to the left along the x-axis (where y=0); and a value of -256 represents the upward direction on the y-axis (where x=0). Naturally, intermediate values represent the intermediate angles.

== Example ==

<code>

%ffp

ForEveryTile:

{

for (y=y_start; y<y_end; ++y)

{

for (x=x_start; x<x_end; ++x)

{

for (z=0; z<Z; ++z)

{

pset(x, y, z, (256 * abs(c2d(x-X/2, y-Y/2)))/512);

}

}

}

return true;

</code>

== Also see ==

:c2m,r2x,r2y

== Comments ==

:Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.