color.c File Reference

Introduction

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...
 
boolean SameColor (Tcolor *c1, Tcolor *c2)
 Identifies identical colors. 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

◆ NewColor()

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 16 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(), ReadOFF(), and TriangulateAtlas().

◆ NewColorWithID()

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

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

◆ CopyColor()

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 59 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(), SimplifyPolyhedron(), and StartNew3dObject().

◆ NullColor()

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

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

Referenced by SetColor3dObject().

◆ SameColor()

boolean SameColor ( Tcolor c1,
Tcolor c2 
)

Returns true if two colors are (almost) the same.

Parameters
c1The first color to compare.
c2The second color to compare.
Returns
TRUE if the two colors are (almost) identical.

Definition at line 71 of file color.c.

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

Referenced by SimplifyPolyhedron().

◆ Add2Color()

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

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

Referenced by AddLeg2World().

◆ ScaleColor()

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

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

◆ AccumulateColor()

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

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

◆ CostColor()

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

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

Referenced by PlotChartAsPolygon(), and TriangulateAtlas().

◆ SetRed()

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

References Tcolor::r.

◆ SetGreen()

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

References Tcolor::g.

◆ SetBlue()

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

References Tcolor::b.

◆ GetRed()

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

References Tcolor::r.

Referenced by body2SDF(), PrintLink(), PrintPolyhedron(), and SavePolyhedron().

◆ GetGreen()

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

References Tcolor::g.

Referenced by body2SDF(), PrintLink(), PrintPolyhedron(), and SavePolyhedron().

◆ GetBlue()

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

References Tcolor::b.

Referenced by body2SDF(), PrintLink(), PrintPolyhedron(), and SavePolyhedron().

◆ PrintColor()

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

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

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

◆ DeleteColor()

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

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