Cairo is a lightweight rendering 2D engine that can be exported to different format results files based on specific bitmap coordinates, such as a common picture format, or PDF format. Cairo also supports access to multiple programming languages and calls to a variety of third-party plug-ins, and is a very easy to use rendering engine.
In Cairo official address, there is a very simple hands-on introduction, give a simple drawing graphics, quickly learn how to draw simple text, lines and text. Here is no longer nonsense, if the English is not good, CSDN also have Chinese translation. English official Introduction please click.
Here also posted two more suitable for the initial start of the address, the drawing process and code explanation are very clear.
The first is to explain the code and code for drawing various graphics using Cairo:
The following is an introduction to the Cairo combined with GTK, including the virtual line, Line_join and LineCap:
This is mainly about using Cairo to draw a surface graph. This is based on an example from the link above. The project requirement is to draw a surface, the surface of the edge and the fill need to use a different width and color . Here are a few core methods Cairo_set_line_width Cairo_stroke_preserve Cairo_fill Cairo_stroke
The following code is posted and detailed introduction
int Draw ()
cairo_set_line_width (CR, 9);
Cairo_set_source_rgb (CR, 0.69, 0.19, 0);
Cairo_translate (CR, WIDTH/2, HEIGHT/2);
Cairo_arc (CR, 0, 0, 0, 2 * m_pi);
Cairo_set_source_rgb (CR, 0.3, 0.4, 0.6);
The preceding code draws a circle with a different color than the fill and sideline. The key is Cairo_stroke_preserve. This method paints the currently drawn brush settings, including width, color values, and the current path information remains in the drawn context. So the next step in executing Cairo_fill is in the context of the current path. This method differs from Cairo_stroke in that the current drawn path information is emptied in the drawing context when the Cairo_stroke drawing finishes.