Cairo-Dock  3.4.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cairo-dock-opengl-path.h File Reference

Data Structures

struct  _CairoDockGLPath
 Definition of a CairoDockGLPath. More...
 

Functions

CairoDockGLPathcairo_dock_new_gl_path (int iNbVertices, double x0, double y0, int iWidth, int iHeight)
 
void cairo_dock_free_gl_path (CairoDockGLPath *pPath)
 
void cairo_dock_gl_path_move_to (CairoDockGLPath *pPath, double x0, double y0)
 
void cairo_dock_gl_path_set_extent (CairoDockGLPath *pPath, int iWidth, int iHeight)
 
void cairo_dock_gl_path_line_to (CairoDockGLPath *pPath, GLfloat x, GLfloat y)
 
void cairo_dock_gl_path_rel_line_to (CairoDockGLPath *pPath, GLfloat dx, GLfloat dy)
 
void cairo_dock_gl_path_curve_to (CairoDockGLPath *pPath, int iNbPoints, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3, GLfloat y3)
 
void cairo_dock_gl_path_rel_curve_to (CairoDockGLPath *pPath, int iNbPoints, GLfloat dx1, GLfloat dy1, GLfloat dx2, GLfloat dy2, GLfloat dx3, GLfloat dy3)
 
void cairo_dock_gl_path_simple_curve_to (CairoDockGLPath *pPath, int iNbPoints, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
 
void cairo_dock_gl_path_rel_simple_curve_to (CairoDockGLPath *pPath, int iNbPoints, GLfloat dx1, GLfloat dy1, GLfloat dx2, GLfloat dy2)
 
void cairo_dock_gl_path_arc (CairoDockGLPath *pPath, int iNbPoints, GLfloat xc, GLfloat yc, double r, double teta0, double cone)
 
void cairo_dock_stroke_gl_path (const CairoDockGLPath *pPath, gboolean bClosePath)
 
void cairo_dock_fill_gl_path (const CairoDockGLPath *pPath, GLuint iTexture)
 
void cairo_dock_draw_rounded_rectangle_opengl (double fFrameWidth, double fFrameHeight, double fRadius, double fLineWidth, double *fLineColor)
 

Detailed Description

This class define OpenGL path, with similar functions as cairo. You create a path with cairo_dock_new_gl_path, then you add lines, curves or arcs to it. Once the path is defined, you can eigher stroke it with cairo_dock_stroke_gl_path or fill it with cairo_dock_fill_gl_path. You can fill a path with the current color or with a texture, in this case you must provide the dimension of the husk. To destroy the path, use cairo_dock_free_gl_path.

Function Documentation

CairoDockGLPath* cairo_dock_new_gl_path ( int  iNbVertices,
double  x0,
double  y0,
int  iWidth,
int  iHeight 
)

Create a new path. It will start at the point (x0, y0). If you want to be abe to fill it with a texture, you can specify here the dimension of the path's husk.

Parameters
iNbVerticesmaximum number of vertices the path will have
x0x coordinate of the origin point
y0y coordinate of the origin point
iWidthwidth of the husk of the path.
iHeightheight of the husk of the path
Returns
a newly allocated path, with 1 point.
void cairo_dock_free_gl_path ( CairoDockGLPath pPath)

Destroy a path and free its allocated ressources.

Parameters
pPaththe path.
void cairo_dock_gl_path_move_to ( CairoDockGLPath pPath,
double  x0,
double  y0 
)

Rewind the path, defining its origin point. The path has only 1 point after a call to this function.

Parameters
pPaththe path.
x0x coordinate of the origin point
y0y coordinate of the origin point
void cairo_dock_gl_path_set_extent ( CairoDockGLPath pPath,
int  iWidth,
int  iHeight 
)

Define the dimension of the hulk. This is needed if you intend to fill the path with a texture.

Parameters
pPaththe path.
iWidthwidth of the hulk
iHeightheight of the hulk
void cairo_dock_gl_path_line_to ( CairoDockGLPath pPath,
GLfloat  x,
GLfloat  y 
)

Add a line between the current point and a given point.

Parameters
pPaththe path.
xx coordinate of the point
yy coordinate of the point
void cairo_dock_gl_path_rel_line_to ( CairoDockGLPath pPath,
GLfloat  dx,
GLfloat  dy 
)

Add a line defined relatively to the current point.

Parameters
pPaththe path.
dxhorizontal offset
dyvertical offset
void cairo_dock_gl_path_curve_to ( CairoDockGLPath pPath,
int  iNbPoints,
GLfloat  x1,
GLfloat  y1,
GLfloat  x2,
GLfloat  y2,
GLfloat  x3,
GLfloat  y3 
)

Add a Bezier cubic curve starting from the current point.

Parameters
pPaththe path.
iNbPointsnumber of points used to discretize the curve
x1first control point x
y1first control point y
x2second control point x
y2second control point y
x3terminal point of the curve x
y3terminal point of the curve y
void cairo_dock_gl_path_rel_curve_to ( CairoDockGLPath pPath,
int  iNbPoints,
GLfloat  dx1,
GLfloat  dy1,
GLfloat  dx2,
GLfloat  dy2,
GLfloat  dx3,
GLfloat  dy3 
)

Add a Bezier cubic curve starting from the current point. The control and terminal points are defined relatively to the current point.

Parameters
pPaththe path.
iNbPointsnumber of points used to discretize the curve
dx1first control point offset x
dy1first control point offset y
dx2second control point offset x
dy2second control point offset y
dx3terminal point of the curve offset x
dy3terminal point of the curve offset y
void cairo_dock_gl_path_simple_curve_to ( CairoDockGLPath pPath,
int  iNbPoints,
GLfloat  x1,
GLfloat  y1,
GLfloat  x2,
GLfloat  y2 
)

Add a Bezier bilinear curve starting from the current point

Parameters
pPaththe path.
iNbPointsnumber of points used to discretize the curve
x1control point x
y1control point y
x2terminal point of the curve x
y2terminal point of the curve y
void cairo_dock_gl_path_rel_simple_curve_to ( CairoDockGLPath pPath,
int  iNbPoints,
GLfloat  dx1,
GLfloat  dy1,
GLfloat  dx2,
GLfloat  dy2 
)

Add a Bezier bilinear curve starting from the current point. The control and terminal points are defined relatively to the current point.

Parameters
pPaththe path.
iNbPointsnumber of points used to discretize the curve
dx1control point offset x
dy1control point offset y
dx2terminal point of the curve offset x
dy2terminal point of the curve offset y
void cairo_dock_gl_path_arc ( CairoDockGLPath pPath,
int  iNbPoints,
GLfloat  xc,
GLfloat  yc,
double  r,
double  teta0,
double  cone 
)

Add an arc to the path, joining the current point to the beginning of the arc with a line.

Parameters
pPaththe path.
iNbPointsnumber of points used to discretize the arc
xcx coordinate of the center
ycy coordinate of the center
rradius
teta0initial angle
conecone of the arc (a negative value means clockwise).
void cairo_dock_stroke_gl_path ( const CairoDockGLPath pPath,
gboolean  bClosePath 
)

Stroke a path with the current color and with the current line width.

Parameters
pPaththe path.
bClosePathwhether to close the path (that is to say, join the last point with the first one) or not.
void cairo_dock_fill_gl_path ( const CairoDockGLPath pPath,
GLuint  iTexture 
)

Fill a path with a texture, or with the current color if the texture is 0.

Parameters
pPaththe path.
iTexturethe texture, or 0 to fill the path with the current color. To fill the path with a gradation, use GL_COLOR_ARRAY and feed it with a table of colors that matches the vertices.
void cairo_dock_draw_rounded_rectangle_opengl ( double  fFrameWidth,
double  fFrameHeight,
double  fRadius,
double  fLineWidth,
double *  fLineColor 
)

Draw a rectangle with rounded corners. The rectangle will be centered at the current point. The current matrix is not altered.

Parameters
fFrameWidthwidth of the rectangle, without the corners.
fFrameHeightheight of the rectangle, including the corners.
fRadiusradius of the corners (can be 0).
fLineWidthwidth of the line. If set to 0, the background will be filled with the provided color, otherwise the path will be stroke with this color.
fLineColorcolor of the line if fLineWidth is non nul, or color of the background otherwise.