+ Collaboration diagram for Colors:

Data Structures

struct  t_jrgb
 A color composed of red, green, and blue components. More...
 
struct  t_jrgba
 A color composed of red, green, blue, and alpha components. More...
 

Functions

void jrgba_to_atoms (t_jrgba *c, t_atom *argv)
 Get the components of a color in an array of pre-allocated atoms. More...
 
t_max_err atoms_to_jrgba (long argc, t_atom *argv, t_jrgba *c)
 Set the components of a color by providing an array of atoms. More...
 
void jrgba_set (t_jrgba *prgba, double r, double g, double b, double a)
 Set the components of a color. More...
 
void jrgba_copy (t_jrgba *dest, t_jrgba *src)
 Copy a color. More...
 
long jrgba_compare (t_jrgba *rgba1, t_jrgba *rgba2)
 Compare two colors for equality. More...
 
t_max_err jrgba_attr_get (t_jrgba *jrgba, long *argc, t_atom **argv)
 Get the value of a t_jrgba struct, returned as an array of atoms with the values for each component. More...
 
t_max_err jrgba_attr_set (t_jrgba *jrgba, long argc, t_atom *argv)
 Set the value of a t_jrgba struct, given an array of atoms with the values to use. More...
 

Detailed Description

Function Documentation

t_max_err atoms_to_jrgba ( long  argc,
t_atom argv,
t_jrgba c 
)

Set the components of a color by providing an array of atoms.

If it is an array of 3 atoms, then the atoms provided should define the red, green, and blue components (in this order) in a range of [0.0, 1.0]. If a 4th atom is provided, it will define the alpha channel. If the alpha channel is not defined then it is assumed to be 1.0.

Parameters
argcThe number of atoms in the array provided in argv. This should be 3 or 4 depending on whether or not the alpha channel is being provided.
argvThe address to the first of an array of atoms that define the color.
cThe address of a t_jrgba struct for which the color will be defined.
Returns
A Max error code.
t_max_err jrgba_attr_get ( t_jrgba jrgba,
long *  argc,
t_atom **  argv 
)

Get the value of a t_jrgba struct, returned as an array of atoms with the values for each component.

Parameters
jrgbaThe color struct whose color will be retrieved.
argcThe address of a variable that will be set with the number of atoms in the argv array. The returned value should be 4. The value of the int should be set to 0 prior to calling this function.
argvThe address of a t_atom pointer that will receive the a new array of atoms set to the values of the jrgba struct. The pointer should be set to NULL prior to calling this function. There should be 4 atoms returned, representing alpha, red, green, and blue components. When you are done using the atoms, you are responsible for freeing the pointer using sysmem_freeptr().
Returns
This function returns the error code MAX_ERR_NONE if successful, or one of the other error codes defined in e_max_errorcodes if unsuccessful.
t_max_err jrgba_attr_set ( t_jrgba jrgba,
long  argc,
t_atom argv 
)

Set the value of a t_jrgba struct, given an array of atoms with the values to use.

Parameters
jrgbaThe color struct whose color will be set.
argcThe number of atoms in the array. This must be 4.
argvThe address of the first of the atoms in the array. There must be 4 atoms, representing alpha, red, green, and blue components.
Returns
This function returns the error code MAX_ERR_NONE if successful, or one of the other error codes defined in e_max_errorcodes if unsuccessful.
long jrgba_compare ( t_jrgba rgba1,
t_jrgba rgba2 
)

Compare two colors for equality.

Parameters
rgba1The address of a t_jrgba struct to compare.
rgba2The address of another t_jrgba struct to compare.
Returns
returns 1 if rgba1 == rgba2.
void jrgba_copy ( t_jrgba dest,
t_jrgba src 
)

Copy a color.

Parameters
destThe address of a t_jrgba struct to which the color will be copied.
srcThe address of a t_jrgba struct from which the color will be copied.
void jrgba_set ( t_jrgba prgba,
double  r,
double  g,
double  b,
double  a 
)

Set the components of a color.

Parameters
prgbaThe address of a t_jrgba struct for which the color will be defined.
rThe value of the red component in a range of [0.0, 1.0].
gThe value of the green component in a range of [0.0, 1.0].
bThe value of the blue component in a range of [0.0, 1.0].
aThe value of the alpha component in a range of [0.0, 1.0].
void jrgba_to_atoms ( t_jrgba c,
t_atom argv 
)

Get the components of a color in an array of pre-allocated atoms.

Parameters
argvThe address to the first of an array of atoms that will hold the result. At least 4 atoms must be allocated, as 4 atoms will be set by this function for the red, green, blue, and alpha components.
cThe address of a t_jrgba struct from which the color components will be fetched.
  Copyright © 2015, Cycling '74