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 CopyColor (Tcolor *c_dst, Tcolor *c_src)
 Copy constructor. More...
 
boolean NullColor (Tcolor *c)
 Identifies a non-valid color. More...
 
void ScaleColor (double s, Tcolor *c)
 Scales 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 InitJoint(), InitPlot3d(), InitPolyhedronFromFile(), InitWorldFromMolecule(), main(), Plot3dObjectWithColors(), PlotAtlas(), PlotAtlasRRT(), PlotBifurcations(), PlotConnection(), PlotEnvironment(), PlotLink(), PlotQrand(), PlotRRT(), PlotSamples(), and TriangulateAtlas().

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 21 of file color.c.

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

Referenced by CopyJoint(), CopyPolyhedron(), GetPolyhedronColor(), InitPolyhedronFromFile(), InitPolyhedronFromTriangles(), NewBox(), NewCylinder(), NewLine(), NewSegments(), NewSphere(), NewSphPrsSphJoint(), NewSphSphJoint(), PlotJoint(), 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 28 of file color.c.

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

Referenced by SetColor3dObject().

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 33 of file color.c.

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

Referenced by PlotJoint().

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 40 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 58 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 63 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 68 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 73 of file color.c.

References Tcolor::r.

Referenced by PrintJoint(), and 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 78 of file color.c.

References Tcolor::g.

Referenced by PrintJoint(), and 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 83 of file color.c.

References Tcolor::b.

Referenced by PrintJoint(), and 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 88 of file color.c.

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

Referenced by Plot3dObjectWithColor(), Plot3dObjectWithColors(), PlotLine(), PlotSegments(), PlotVect3d(), 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 93 of file color.c.

Referenced by DeleteJoint(), InitWorldFromMolecule(), main(), PlotAtlas(), PlotAtlasRRT(), PlotBifurcations(), PlotConnection(), PlotEnvironment(), PlotJoint(), PlotLink(), PlotQrand(), PlotRRT(), and PlotSamples().