Module corky.cairo
Corky interface to Cairo.
This module may be used to clean up the global namespace and remove all cairo_*
and CAIRO_*
variables and
functions. All of these variables/functions may then be accessed using the table returned by this module (with
or without "cairo_"
/"CAIRO_"
prefix).
Conky's cairo
module will be require
d by this module automatically.
Usage example:
local cairo = require "corky.cairo" -- Initialize surface and context: cairo.init () -- Using long names: cairo.cairo_show_text (cairo.context, "Some text…") -- The same using short names: cairo.show_text (cairo.c, "Some text…") -- Clean up: cairo.clean_up ()
Cairo Surface And Context Properties:
The properties surface
(alias s
) and context
(alias c
) will be provided by this module, see the example
above. They may be initialized by calling the init() function, and destroyed by calling the
function clean_up(). It is of course possible to manually create another surface and/or
context, if required.
Note: If the main module is used, init() and clean_up() will be called before and after the draw hooks, respectively.
Info:
Functions
setup () | Setup the Cairo functions and variables. |
init () | Initialize a Cairo surface and context. |
clean_up () | Free the resources used by the surface and context. |
Local Functions
meta.__index (self, key) | Return a cairo_* variable/function, or the surface or context. |
Local Tables
meta | The meta table for the corky.cairo table. |
Functions
- setup () line 83
-
Setup the Cairo functions and variables.
This function will be called automatically when the module is loaded!
This function will remove all global variables and functions with a name starting with
"cairo_"
or"CAIRO_"
from the global namespace. They will be available in the table returned by this module.Calling this function multiple times is allowed, but usually not necessary.
- init () line 106
-
Initialize a Cairo surface and context.
This function will create a Cairo surface and a context that may be used for drawing to the Conky window.
After the initialization the surface may be accessed using the
surface
property (or the aliass
), the context may be accessed using thecontext
property (aliasc
). Both may benil
if they are not yet initialized or the initialization failed. It is recommended to check this before using them.The clean_up() function may be used to destroy both the surface and the context.
- clean_up () line 134
-
Free the resources used by the surface and context.
This function will call Cairo's
destroy()
function for the context and thesurface_destroy()
function for the surface created by the init() function. After that, thecontext
andsurface
properties will benil
and can no longer be used for drawing.
Local Functions
- meta.__index (self, key) line 173
-
Return a
cairo_*
variable/function, or the surface or context.The key parameter specifies the name of the variable or function to return. It may include the
"cairo_"
(or"CAIRO_"
) prefix, it will be automatically added if it does not (with the exception of the keys"surface"
,"s"
,"context"
and"c"
).Parameters:
Returns:
-
The requested variable or function, or
nil
if it does not exist.
-
The requested variable or function, or
Local Tables
- meta line 160
-
The meta table for the
corky.cairo
table.Provides a custom indexer to access the
cairo_*
stuff.