My favorites | Sign in
Project Logo
                
Search
for
Updated Sep 21, 2008 by bgoo...@guarana.org
Labels: Featured
Tutorial  
First steps with a basic example

To compile erlycairo from an SVN checkout (no tarballs available as yet)

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().

Sign in to add a comment
Hosted by Google Code