Supported since 1.15.
This page presents an overview of Efl.Gfx.Filter used for advanced text effects and basic image filtering.
Since 1.19 textblock also supports filters by using the “gfx_filter” format tag. Since 1.20 most filters have GL acceleration.
Summary of the supported filtering functions:
The Eo class Efl.Gfx.Filter provides an interface for Evas objects (currently only Evas.Text and Evas.Image) to alter their appearance by applying a series of filtering operations. Filtered objects will be rendered in internal surfaces and transformed before being drawn on the canvas. Objects without a filter are rendered directly on the canvas.
EFL provides a set of standard core filters that can be combined by using a simple script. Custom filters can be written in Lua (5.1) and can be a combinaison of any number of the base filters presented below.
The filters work by taking an input
buffer (or image), applying some effects on it, and drawing the result to an output
buffer. This final image is rendered on the canvas.
Since Efl.Gfx.Filter works on both Evas.Image and Evas.Text objects, the input
buffer can contain respectively a scaled copy of the source image (RGBA), or the text string rendered as an Alpha-only buffer, like this:
Since the filters may modify pixels based on their neighbors (blur) or move pixels around (displace, transform), a filter ends up requiring the input buffer to be padded to avoid cropping of the effect. The filter engine will automatically compute the necessary padding for you, but this may be too much in some situations (eg. blur 10 + blur 20 will add a padding of 30 but most pixels will be blank).
You can set the padding to a fixed value with the padding_set command.
The following table lists all the core filter functions, applied to an Evas.Text object.
Feature | Function | Example |
---|---|---|
Blend | blend | |
Blurs, glows and shadows | blur | |
Grow and shrink | grow | |
Color curves | curve | |
Solid color fill | fill | |
Masking and texturing | mask | |
Bump maps | bump | |
Displacement maps | displace | |
Transformation | transform |
Graphics filters in EFL can be described by short Lua scripts. Various graphics buffers can be combined and mixed together using other objects from the canvas as sources.
Here is an example of a very simple filter using only the blur
and grow
functions:
blur { 10, color = '#009' } blur { 4, color = '#f00' } grow { -4 }
Step by step, this is how Evas generates the final output.
#009
, which is equivalent to #000099
or rgba(0, 0, 0x99, 0xff)
.
The Evas filter system is based around the use of various “buffers”, which can be either Alpha masks or full RGBA color images. The following example uses an intermediate buffer to store the output of the grow
command, and use that as input for the blur
command:
a = buffer { 'alpha' } -- step 1 grow { 6, dst = a } -- step 2 blur { 4, src = a, color = '#009' } -- step 3 blend { src = input } -- step 4
Step by step, this is what happens to the contents of our buffers.