"Rendering Engine" Cairo introduction

Source: Internet
Author: User
Tags cairo

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_stroke_preserve (CR);

    Cairo_set_source_rgb (CR, 0.3, 0.4, 0.6); 
    Cairo_fill (CR);

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.