bx-lib : the Basic X11 Library tuned for C beginners  1.0
Functions
Setting the active pen attributes
Pen (what you use to draw on a canvas)

Functions

void bx_set_line_style (bx_line_style line_style)
void bx_set_color (bx_color color)
void bx_set_color2 (bx_color color)
void bx_set_rgb (unsigned char r, unsigned char g, unsigned char b)
void bx_set_rgb2 (unsigned char r, unsigned char g, unsigned char b)
void bx_set_line_width (unsigned int size)
void bx_set_fill_style (bx_fill_style fill_style)
void bx_set_tile_image (bx_image image)
void bx_set_tile_origin (int x, int y)
void bx_set_fill_rule (bx_fill_rule fill_rule)
void bx_set_effect (bx_effect fx)

Detailed Description

Function Documentation

void bx_set_line_style ( bx_line_style  line_style)

Sets the line style used to draw contours of shapes (solid lines, doubly dashed lines, or dashed lines).

Parameters
line_stylethe line style to activate.
Returns
nothing.
void bx_set_color ( bx_color  color)

Sets the principal color used by the pen for all drawing functions.

Parameters
colorthe new color used by the pen.
Returns
nothing.
Remarks
void bx_set_color2 ( bx_color  color)

Sets the secondary color used by the pen for all drawing functions. The secondary color is used for doubly dashed lines.

Parameters
colorthe new color used by the pen.
Returns
nothing.
Remarks
void bx_set_rgb ( unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Sets the principal color of the pen for all drawing functions, directly from a RGB triplet. If you do not reuse this color later, you may want to use this function instead of bx_set_color(). This is just equivalent to bx_set_color (bx_rgb_to_color (r,g,b));

Parameters
r,g,bthe red, green, blue channel of the color.
Returns
nothing.
Remarks
  • The default color of the pen is black.
void bx_set_rgb2 ( unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Sets the secondary color of the pen for all drawing functions, directly from a RGB triplet. If you do not reuse this color later, you may want to use this function instead of bx_set_color(). This is just equivalent to bx_set_color2 (bx_rgb_to_color (r,g,b));

Parameters
r,g,bthe red, green, blue channel of the color.
Returns
nothing.
Remarks
  • The default secondary color of the pen is white.
void bx_set_line_width ( unsigned int  size)

Sets the line width of the pen for drawing functions like bx_draw_line (), bx_draw_circle ()...

Parameters
sizethe new width of the pen
Returns
nothing.
Remarks
  • The default line width of the pen is 0.
bx_set_line_width.jpg
#include <bx.h>
int main (void)
{
bx_window win;
int k, margin= 10, nb_samples= 10;
int sample_width= 30, sample_height= 60;
int w= margin + (sample_width + margin)* nb_samples;
int h= margin + sample_height + margin;
bx_init ();
win= bx_create_window ("bx_set_line_width", 10 , 10, w, h);
for (k= 0; k < nb_samples; k++) {
int x= margin + k*(sample_width + margin);
int y= margin;
bx_draw_line (win, x, y, x+sample_width, y+sample_height);
}
bx_show_canvas (win, 0);
return 0;
}
void bx_set_fill_style ( bx_fill_style  fill_style)

Sets the fill style used to paint the interior of shapes. Two styles are supported : plain solid fill style and "bathroom tile" style using an image as a repeating motif.

Parameters
fill_stylethe fill style to set as active
Returns
nothing.
Remarks
void bx_set_tile_image ( bx_image  image)

Sets the repeating "bathroom tile" pattern to use for filling shapes if bx_set_fill_style() was called with BX_TILED_FILL.

Parameters
theimage to use as a repeating pattern
Returns
nothing.
void bx_set_tile_origin ( int  x,
int  y 
)

Shifts the locations of repeating "bathroom tile" patterns used for filling shapes if bx_set_fill_style() was called with BX_TILED_FILL.

Parameters
xx-coordinate of the top-left-corner of the starting tile
yy-coordinate of the top-left-corner of the starting tile
Returns
nothing.
void bx_set_fill_rule ( bx_fill_rule  fill_rule)

Sets how a self-intersecting polygon should be filled. Two rules are possible: The winding rule and the odd-even rule.

Parameters
fill_rulethe rule to apply for next drawing functions
Returns
nothing.
void bx_set_effect ( bx_effect  fx)

Sets a special effect selected among 16 for all drawing functions with the notable exception of bx_draw_image().

Parameters
fxthe special effect to apply, in the range from 0 to 15.
Returns
nothing.
Remarks
  • See bx_effect for details.
  • The default fx is BX_A, that is, the source is copied on the destination.
  • bx_set_effect() has no effect on bx_draw_image(). This is because bx-lib has to deal transparent and opaque images differently with special effect. Use bx_draw_image_fx() instead to get the expected result.