pset

Syntax

int pset(int x, int y, int z, int v)

Arguments

x
An integer pixel x-coordinate in the output buffer.
y
An integer pixel y-coordinate in the output buffer.
z
An integer channel number in the range 0 to Z - 1.
v
An integer value to be set for channel 'z'.

Return

Returns the value of v, properly clamped to the range [0, 255] or [0, 0x8000], if the current pixel depth is 8 or 16 bits, respectively.

Description

This function sets the value of one channel for a pixel in the output buffer to the properly clamped value of v. The pixel is at coordinates (x,y), and the channel to be set is given by 'z' (0 = red, 1 = green, 2 = blue, and 3 = alpha for the RGBA case).
If the coordinates (x,y) are outside the current image (i.e., x < 0 or x >= (X)? or y < 0 or y >= (Y)?), or if z < 0 or z >= Z, then the output buffer is not changed.

Example

%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, 255);  // set all (8-bit) pixels to white!
			}
		}
	}
	return true;
}

Also see

tset, t2set, pget

Comments

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