cairopp is a C++17 binding for cairo (>= 1.16).
- Ease of use: everything is in a single header, just drop the header in your source tree.
- Strict binding: the API is exactly the same as cairo with just unavoidable exceptions.
- Quality of life: additional structs for points, rectangles, colors, etc.
Everything is in the cairo namespace.
The binding sticks to the original cairo library. A function cairo_foo_do_something is generally transformed in a member function do_something of class Foo in the cairo namespace: cairo::Foo::do_something. The get_ prefix are removed.
The enumeration members lose their prefix, but as they are in an enum class, an enumeration member CAIRO_BAR_BAZ is generally transformed into cairo::Bar::Baz.
To follow the binding guidelines, many constructors are replaced with static member functions. In particular, all surfaces are created with static member functions.
For each member function that have x and y or width and height, an overload is provided with a Vec2F (for doubles) or Vec2I (for ints) parameter. For each member function that have x and y and width and height, an overload is provided with a RectF (for doubles) or RectI (for ints) parameter For each member function that have a red, green, blue and possibly alpha, an overload is provided with a Color parameter.
When two parameters represents an array and the size of the array, a templated overload is provided that use std::data and std::size to get the associated data and size of the templated container. So it can be used with std::array, std::vector and even with std::initializer_list.
They are a number of missing things, it can be because there are callbacks (and I have to find a good way to handle them), or because it's not yet here (e.g. the many surfaces and devices), or because I don't want to support them. Anyway, pull requests are welcome to complete the binding.
Known missing classes:
user_scaled_fontuser_font_facesurface_observerraster_source_patternregion
Known missing member functions:
*::get_reference_count*::get_user_data*::set_user_datasurface::write_to_png_streamsurface::set_mime_datasurface::get_mime_datasurface::supports_mime_typeimage_surface::create_from_png_stream
The binding handles the different versions from 1.16. If you need support for version handling before 1.16, patches are welcome.
This binding is released under the MIT license.