-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial
bernardd edited this page Sep 9, 2014
·
1 revision
To compile erlycairo from a git checkout:
aclocal autoconf automake -a ./configure make sudo make install
Now, fire up an Erlang VM with a node name:
erl -sname mynode
Now start the OTP server:
> application:start(erlycairo).
Example copy-pasted from the demo application:
create_images()->
rect("images/rect.png", 100, 100, {1.0, 0.2, 0.7, 1.0}).
rect(File, Width, Height, {Red, Green, Blue, Alpha}) ->
case erlycairo_server:new_image_blank(Width, Height) of
{ok, Ctx} ->
erlycairo_server:set_source_rgba(Ctx, Red, Green, Blue, Alpha),
erlycairo_server:rectangle(Ctx, 0, 0, Width, Height),
erlycairo_server:fill(Ctx),
erlycairo_server:write_to_png(Ctx, File),
erlycairo_server:close_image(Ctx),
ok;
{error, Reason} ->
exit(Reason)
end.
This code is already available in the erlycairo_demo module. To run it, just use:
> erlycairo_demo:create_images().