color.c File Reference

Detailed Description

Implementation of the functions working on colors as red/green/blue components.

See Also
Tcolor, color.h.

Definition in file color.c.

Functions

void NewColor (double r, double g, double b, Tcolor *c)
 Constructor. More...
 
void NewColorWithID (unsigned int id, Tcolor *c)
 Constructor. More...
 
void CopyColor (Tcolor *c_dst, Tcolor *c_src)
 Copy constructor. More...
 
boolean NullColor (Tcolor *c)
 Identifies a non-valid color. More...
 
void Add2Color (double s, Tcolor *c)
 Adds to a color. More...
 
void ScaleColor (double s, Tcolor *c)
 Scales a color. More...
 
void AccumulateColor (Tcolor *c1, Tcolor *c)
 Adds a color. More...
 
void CostColor (double cost, double minCost, Tcolor *c)
 Definees a color in function of a cost. More...
 
void SetRed (double r, Tcolor *c)
 Changes the red component of a color. More...
 
void SetGreen (double g, Tcolor *c)
 Changes the green component of a color. More...
 
void SetBlue (double b, Tcolor *c)
 Changes the blue component of a color. More...
 
double GetRed (Tcolor *c)
 Gets the red component of a color. More...
 
double GetGreen (Tcolor *c)
 Gets the green component of a color. More...
 
double GetBlue (Tcolor *c)
 Gets the blue component of a color. More...
 
void PrintColor (FILE *f, Tcolor *c)
 Prints the color. More...
 
void DeleteColor (Tcolor *c)
 Destructor. More...
 

Function Documentation

void NewColor ( double  r,
double  g,
double  b,
Tcolor c 
)

Creates new color.

Parameters
rThe red component for the new color.
gThe green component for the new color.
bThe blue component for the new color.
cThe color to intialize.

Definition at line 14 of file color.c.

References Tcolor::b, Tcolor::g, and Tcolor::r.

Referenced by InitPlot3d(), InitPolyhedronFromFile(), InitWorldFromMolecule(), main(), NewColorWithID(), Plot3dObjectWithColors(), PlotAtlas(), PlotAtlasRRT(), PlotBifurcations(), PlotConnection(), PlotEnvironment(), PlotForceField(), PlotLink(), PlotQrand(), PlotRRT(), PlotSamples(), and TriangulateAtlas().

void NewColorWithID ( unsigned int  id,
Tcolor c 
)

Creates new color.

Parameters
idIdentifier of the color (0 for red, etc).
cThe color to intialize.

Definition at line 21 of file color.c.

References BLACK, BLUE, CYAN, Error(), GREEN, GREY, NewColor(), PURPLE, RED, WHITE, and YELLOW.

void CopyColor ( Tcolor c_dst,
Tcolor c_src 
)

Creates new color from another color.

Parameters
c_dstThe color to create.
c_srcThe color from where to copy.

Definition at line 57 of file color.c.

References Tcolor::b, Tcolor::g, and Tcolor::r.

Referenced by AddLeg2World(), CopyPolyhedron(), GetPolyhedronColor(), InitPolyhedronFromFile(), InitPolyhedronFromTriangles(), NewBox(), NewCylinder(), NewLine(), NewSegments(), NewSphere(), NewSpring(), NewTriangularPrism(), SetPolyhedronColor(), and StartNew3dObject().

boolean NullColor ( Tcolor c)

Identifies colors with negative values of red, green or blue.

Null-color is used to define a 3d object whose color does not need to be set globally since the elements of in the 3d objec already define its color.

Parameters
cThe color to query.
Returns
TRUE if the color is null.

Definition at line 64 of file color.c.

References Tcolor::b, Tcolor::g, and Tcolor::r.

Referenced by SetColor3dObject().

void Add2Color ( double  s,
Tcolor c 
)

Creates new color by a constant factor to all the components of a given color.

Parameters
sThe factor to add.
cThe color to modify.

Definition at line 69 of file color.c.

References Tcolor::b, Tcolor::g, and Tcolor::r.

Referenced by AddLeg2World().

void ScaleColor ( double  s,
Tcolor c 
)

Creates new color by scaling a existing color. Scale factors larger than one create lighter colors and scale factors below one create darker colors.

Parameters
sThe scale factor.
cThe color to scale.

Definition at line 76 of file color.c.

References Tcolor::b, Tcolor::g, and Tcolor::r.

void AccumulateColor ( Tcolor c1,
Tcolor c 
)

Creates new color by adding two colors.

Parameters
c1The color to add.
cThe color where to accumulate c1.

Definition at line 83 of file color.c.

References Tcolor::b, Tcolor::g, and Tcolor::r.

void CostColor ( double  cost,
double  minCost,
Tcolor c 
)

Defines a color in function of a cost. The lowest cost is plot in black and the rest in a gradient from red to green.

This is basically used to color atlas (and atlases triangulations) with associated cost functions.

Parameters
costThe cost. Must be scaled in [0,1].
minCostThreshold from below which the cost is considered zero. Color below this cost is black.
cThe color to define.

Definition at line 90 of file color.c.

References Tcolor::b, Tcolor::g, and Tcolor::r.

Referenced by PlotChartAsPolygon(), and TriangulateAtlas().

void SetRed ( double  r,
Tcolor c 
)

Changes the red component of a color.

Parameters
rThe new red component.
cThe color to update.

Definition at line 108 of file color.c.

References Tcolor::r.

void SetGreen ( double  g,
Tcolor c 
)

Changes the green component of a color.

Parameters
gThe new green component.
cThe color to update.

Definition at line 113 of file color.c.

References Tcolor::g.

void SetBlue ( double  b,
Tcolor c 
)

Changes the blue component of a color.

Parameters
bThe new blue component.
cThe color to update.

Definition at line 118 of file color.c.

References Tcolor::b.

double GetRed ( Tcolor c)

Gets the red component of a color.

Parameters
cThe color to query.
Returns
The red component of the color.

Definition at line 123 of file color.c.

References Tcolor::r.

Referenced by PrintPolyhedron().

double GetGreen ( Tcolor c)

Gets the green component of a color.

Parameters
cThe color to query.
Returns
The green component of the color.

Definition at line 128 of file color.c.

References Tcolor::g.

Referenced by PrintPolyhedron().

double GetBlue ( Tcolor c)

Gets the blue component of a color.

Parameters
cThe color to query.
Returns
The blue component of the color.

Definition at line 133 of file color.c.

References Tcolor::b.

Referenced by PrintPolyhedron().

void PrintColor ( FILE *  f,
Tcolor c 
)

Prints the three components of a color in a file.

The componts (red, blue, and green) are printed as doubles, without any separation mark. This is the way in which Geomview uses colors.

See Also
plot3d.h, Tplot3d.
Parameters
fThe file where to write the color
cThe color to print.

Definition at line 138 of file color.c.

References Tcolor::b, Tcolor::g, and Tcolor::r.

Referenced by Plot3dObjectWithColor(), Plot3dObjectWithColors(), PlotLine(), PlotSegments(), PlotVect3d(), PrintMechanism(), and SetColor3dObject().

void DeleteColor ( Tcolor c)

Deletes the information stored in a Tcolor and frees the allocated memory, if any.

Parameters
cThe color to delete.

Definition at line 143 of file color.c.

Referenced by AddLeg2World(), InitWorldFromMolecule(), main(), PlotAtlas(), PlotAtlasRRT(), PlotBifurcations(), PlotConnection(), PlotEnvironment(), PlotForceField(), PlotLink(), PlotQrand(), PlotRRT(), PlotSamples(), and PrintMechanism().