api index


graphicsDeploy api:
pattern.h

Library for 2d patterns and gradients. patternColor() and gradientColor() do the brunt of the work, these being functions which look up the correct color of a pixel dependent on its position in relation to the space being filled.


Patterns

The State struct of patterns is simply an Image struct. Image structs have associated staggering parameters which is interpreted here by patternColor().

struct Image *checkerboard(Color color1, Color color2, long checker_size);
struct Image *stripe(Color color1, Color color2, long stripe_width, short stripe_direction);

#define HORIZ 0;
#define VERT 1;
#define DIAG_UP 2;
#define DIAG_DOWN 3;

Color patternColor(struct State *state, ImagePoint index);

Gradients

Properly formed gradients have two lists of the same length, one of colors and one of relative color positions along the gradient. These position values should range from 0.0 to 1.0, in order. The gradient type affects the manner in which gradientColor() calculates the position of a point along a gradient, and interpolation type affects the manner in which intermediate colors are determined.

struct Gradient {
   short gradtype, interptype; /* one of available types below */
   short relative; /* TRUE or FALSE */
   int ncolors;
   double angle;
   Color *colors;
   double *pos;
};

/* gradient types */
#define CARTESIAN 0
#define RADIAL 1
#define ANGULAR 2
#define PYRAMID 3

/* interpolation types */
#define STEP 0
#define LINEAR 1
struct Gradient *newGradient(int num_colors, double angle, Color *colors,
   double *positions, short gradient_type, short interpolation_type,
   short bool_relative);
struct Gradient *copyGradient(struct Gradient *gradient);
void freeGradient(struct Gradient *gradient);

Color gradientColor(struct State *state, ImagePoint index, ImagePoint reference);



api index