<div dir="ltr">Hi,<br><br>Cairo is a 2D graphics library.<br><a href="http://www.cairographics.org/">http://www.cairographics.org/</a><br>erlycairo uses a c-node to talk to cairo.<br><a href="http://code.google.com/p/erlycairo/">http://code.google.com/p/erlycairo/</a><br>
I'm using erlycairo to draw an image on the server.<br>I'm sending a path with ~40 points every 1/2 second and draw it on a 800x1200 px canvas.<br><br>I'm getting 60% cpu load.<br>When removing the last part which writes the canvas context to a png stream, I'm getting 20% cpu load.<br>
Is there a reason why it produces such a big load on the cpu?<br>Is there something I can do to decrease it?<br>Are there other options to draw on a canvas which might be better?<br><br>This is the code I'm using:<br>
<br>{ok, Ctx} = erlycairo_server:new_image_blank(800, 1200),<br>% load previous stream (not shown)<br>erlycairo_server:set_source_rgba(Ctx, R, G, B, 1.0),<br>erlycairo_server:move_to(Ctx, X0, Y0),<br>lists:foreach(fun({X, Y}) -><br>
  erlycairo_server:line_to(Ctx, X, Y)<br>end, Path),<br>erlycairo_server:set_line_width(Ctx, 1),<br>erlycairo_server:stroke(Ctx),<br>{ok, Stream} = erlycairo_server:write_to_png_stream(Ctx),<br>% save the stream (not shown)<br>
erlycairo_server:close_image(Ctx).<br><br>Thanks<br><br><br></div>