... | ... | @@ -4,16 +4,22 @@ Each heading below is a link to the JavaScript source, which are decently docume |
|
|
|
|
|
### Cairo
|
|
|
|
|
|
Mostly API compatible with [cairo](https://www.cairographics.org/documentation/), but using camelCase function names. A simple example drawing a 32x32 red circle:
|
|
|
Mostly API compatible with [cairo](https://www.cairographics.org/documentation/), but using camelCase function names. There is list of constants in [cairo.js][cairo-const] and functions for each object in it's corresponding C++ file (eg. [cairo-context.cpp][cairo-func]). A simple example drawing a 32x32 red circle:
|
|
|
|
|
|
```js
|
|
|
imports.gi.versions.Gtk = "3.0";
|
|
|
const Gtk = imports.gi.Gtk;
|
|
|
const Cairo = imports.cairo;
|
|
|
|
|
|
let drawingArea = new Gtk.DrawingArea({
|
|
|
height_request: 32,
|
|
|
width_request: 32
|
|
|
});
|
|
|
|
|
|
drawingArea.connect("draw", (widget, cr) => {
|
|
|
// Cairo in GJS uses camelCase function names
|
|
|
cr.setSourceRGB(255, 0, 0);
|
|
|
cr.setOperator(Cairo.Operator.DEST_OVER);
|
|
|
cr.arc(16, 16, 16, 0, 2*Math.PI);
|
|
|
cr.fill();
|
|
|
// currently when you connect to a draw signal you have to call
|
... | ... | @@ -23,6 +29,9 @@ drawingArea.connect("draw", (widget, cr) => { |
|
|
});
|
|
|
```
|
|
|
|
|
|
[cairo-const]: https://gitlab.gnome.org/GNOME/gjs/blob/master/modules/cairo.js
|
|
|
[cairo-func]: https://gitlab.gnome.org/GNOME/gjs/blob/master/modules/cairo-context.cpp#L825
|
|
|
|
|
|
### [Format](https://gitlab.gnome.org/GNOME/gjs/blob/master/modules/format.js)
|
|
|
|
|
|
Provides `vprintf()`, `printf()` and the `format()` method meant to be applied to the String prototype.
|
... | ... | |