Wiki source for ExtLibcairo

Show raw source

{{fbdoc item="title" value="Cairo"}}----
2D graphics library with support for multiple output devices. It can be used to draw on multiple different surfaces, such as the FB graphics window, in-memory pixel buffers, a GTK+ widget or a ""Win32"" window or device context.

Platforms supported: ""Win32"", Linux
Headers to include: cairo/
Header version: 1.14.2
Examples: yes, in examples/graphics/cairo/

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/libraries/cairo.bas"}}%%(freebasic)
'' Example showing cairo being used to draw into the FB graphics window
#include once "cairo/"

Const SCREEN_W = 400
Const SCREEN_H = 300

ScreenRes SCREEN_W, SCREEN_H, 32

'' Create a cairo drawing context, using the FB screen as surface.
var surface = cairo_image_surface_create_for_data(ScreenPtr(), CAIRO_FORMAT_ARGB32, SCREEN_W, SCREEN_H, SCREEN_W * SizeOf(ULong))

var c = cairo_create(surface)


'' Draw the entire context white.
cairo_set_source_rgba(c, 1, 1, 1, 1)

'' Draw a red line
cairo_set_line_width(c, 1)
cairo_set_source_rgba(c, 1, 0, 0, 1)
cairo_move_to(c, 0, 0)
cairo_line_to(c, SCREEN_W - 1, SCREEN_H - 1)



'' Clean up the cairo context

{{fbdoc item="back" value="ExtLibTOC|External Library Table of Contents"}}

// last reviewed: ""MrSwiss"", 2018-05-05 -- changed: ""SizeOf""(Integer) to ""SizeOf""(ULong) reason: 32/64 compatibility //
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode