Set Cairo line width in JavaScript

Hi all:

I’m doing some graphics with cairo in Javascript, and I found that I can’t set the line width. In official documentation I should use gdk_cairo_set_line_width(context, new_width); so in Javascript it should be:



Gdk.cairo_set_line_width(cr, new_width);

but both constructions fail… What should I do?


1 Like

That would be a bug in the documentation. Gdk includes some API to integrate its own data types with cairo, but cairo_set_line_width() is part of cairo itself.

Cairo doesn’t use the GObject type system, so it is not introspectable itself. gobject-introspection includes a minimal GIR/typelib for cairo, but that only wraps some types that appear in other APIs (like GDK/GTK).

Bindings that want to expose the cairo API themselves need to implement a custom binding.

gjs does that, but it doesn’t expose different case styles like it does for introspected API. That is, you have to use camelCase, not snake_case:

1 Like

It worked. Thanks!!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.