카이로 (그래픽스)

위키백과, 우리 모두의 백과사전.

카이로
원저자Keith Packard, Carl Worth[1]
개발자Carl Worth, Behdad Esfahbod
발표일Before 2003년(21년 전)(2003)[2]
저장소gitlab.freedesktop.org/cairo/cairo
프로그래밍 언어C
종류그래픽스 라이브러리
라이선스GNU LGPL 버전 2.1 (전용) 또는 모질라 퍼블릭 라이선스 1.1
웹사이트www.cairographics.org

카이로벡터 그래픽스 기반 장치 독립 API를 제공하는, 소프트웨어 개발자를 위한 오픈 소스 그래픽스 라이브러리이다. 수많은 백엔드를 가로지르는 2차원 드로잉을 위한 프리미티브를 제공한다. 카이로는 사용 가능한 경우 하드웨어 가속을 사용한다.

예시 코드[편집]

#include <cairo-svg.h>
#include <stdio.h>

int main(int argc, char **argv) {
    cairo_surface_t *surface = cairo_svg_surface_create("Cairo_example.svg", 100.0, 100.0);
    cairo_t *cr = cairo_create(surface);

    /* Draw the squares in the background */
    for (int x = 0; x < 10; ++x)
       for (int y = 0; y < 10; ++y)
           cairo_rectangle(cr, x * 10.0, y * 10.0, 5, 5);

    cairo_pattern_t *pattern = cairo_pattern_create_radial(50, 50, 5, 50, 50, 50);
    cairo_pattern_add_color_stop_rgb(pattern, 0, 0.75, 0.15, 0.99);
    cairo_pattern_add_color_stop_rgb(pattern, 0.9, 1, 1, 1);

    cairo_set_source(cr, pattern);
    cairo_fill(cr);

    /* Writing in the foreground */
    cairo_set_font_size (cr, 15);
    cairo_select_font_face (cr, "Georgia", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
    cairo_set_source_rgb (cr, 0, 0, 0);

    cairo_move_to(cr, 10, 25);
    cairo_show_text(cr, "Hallo");

    cairo_move_to(cr, 10, 75);
    cairo_show_text(cr, "Wikipedia!");

    cairo_destroy(cr);
    cairo_surface_destroy(surface);
}

같이 보기[편집]

외부 링크[편집]

  1. “Carl's boring web pages”. 《cworth.org》. 2013. 2014년 7월 11일에 확인함. 
  2. “Xr: Cross-device Rendering for Vector Graphics”. 2009년 6월 8일에 확인함.