ARGB Graphics Made Easy
Many people dismiss Enlightenment’s cool GUI effects as just “hacks” that are no substitute for real transparency. That may have been true in the past when X didn’t have such features, but thanks to the new Xrender engine in Evas, it’s no longer true. For the skeptics, here’s a little 48-line program that can display any Edje file with full transparency (when a composite manager is running). Don’t try this with XLib.
#include <stdio.h>
#include <stdlib.h>
#include <Evas.h>
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <Edje.h>
int main(int argc, char ** argv)
{
Evas *evas;
Ecore_Evas *ee;
Evas_Object *edje;
if (argc < 2)
exit(1);
ecore_init();
ecore_app_args_set(argc, (const char **)argv);
ecore_evas_init();
ee = ecore_evas_xrender_x11_new(0, 0, 0, 0, 400, 400);
evas = ecore_evas_get(ee);
ecore_evas_alpha_set(ee, 1);
ecore_evas_title_set(ee, "MAGIC!");
ecore_evas_borderless_set(ee, 1);
edje_init();
edje_frametime_set(1.0/30.0);
ecore_evas_move(ee, 0, 0);
edje = edje_object_add(evas);
if (!edje_object_file_set(edje, argv[1], "Main"))
{
fprintf(stderr, "Failed to load collection 'Main' from Edje file %s\n",
argv[1]);
exit(1);
}
evas_object_move(edje, 0, 0);
ecore_evas_resize(ee, 200, 200);
evas_object_resize(edje, 200, 200);
evas_object_show(edje);
ecore_evas_show(ee);
ecore_main_loop_begin();
edje_shutdown();
ecore_evas_shutdown();
ecore_shutdown();
return 0;
}
Two examples are shown here — a static camera image and an animated E logo:
You can download the source, together with the two sample edjes here. You need to have Evas, Ecore and Edje installed (visit Get-E.org for more info). This all comes with a minor caveat: Xrender performance generally ranges from sucky to depressing, and as a result evas_xrender is approximately 10 times slower than the plain software engine. But any decently fast computer should be able to handle this test case with ease.

