gray

Syntax

int gray(int r, int g, int b, int rweight, int gweight, int bweight)

Arguments

r
The Red pixel color value
g
The Green pixel color value
b
The Blue pixel color value
rweight
The weighting given to the red color in the grayscale algorithm
gweight
The weighting given to the green color in the grayscale algorithm
bweight
The weighting given to the blue color in the grayscale algorithm

Return

The new grayscale pixel value.

Description

Applies a simple grayscale effect to a given RGB pixel value, according to the weightings provided.

Example

ctl[0]: "Red Weight", Range=(1,500), Val=250
ctl[1]: "Green Weight", Range=(1,500), Val=250
ctl[2]: "Blue Weight", Range=(1,500), Val=250

ForEveryTile: {
  int r, g, b;
  for (y = y_start; y < y_end; y++) {
    for (x = x_start; x < x_end; x++) {
       r = src(x,y,0);
       g = src(x,y,1);
       b = src(x,y,2);
       for (z=0; z < 3; z++) {
          pset(x,y,z, gray(r, g, b, ctl(0), ctl(1), ctl(2)));
       }
    }
  }
  return true;
}

See Also

blend, contrast, saturation