|
|
Home » Developing U++ » UppHub » Cairo
|
|
|
Re: Cairo [message #19713 is a reply to message #19710] |
Tue, 06 January 2009 23:23   |
kodos
Messages: 111 Registered: March 2008
|
Experienced Member |
|
|
luzr wrote on Tue, 06 January 2009 20:32 |
What we REALLY need is to draw to ImageBuffer. And provide meaningful way how to store such drawing and how to print it (like DrawingDraw).
This really is multitarget effort - and one important target is to support drawing in non-GUI apps (think webservers).
Once you have rendered raster in ImageBuffer, providing Ctrl is trivial.
Mirek
|
The Linux control is actually just a wrapper around my cairo class which renders to an image buffer and after that the image buffer is rendered to a control. I think cairo also supports printing, but never tested that one .
This are the 4 methods that are currently implemented to set/create a cairo surface:
void SetSurface(cairo_surface_t *surface, int width, int height);
void SetSurface(ImageBuffer &img);
void CreateSvgSurface(String const &filename, double widthInPoints = 595, double heightInPoints = 841);
void CreatePdfSurface(String const &filename, double widthInPoints = 595, double heightInPoints = 841);
|
|
|
|
|
|
|
|
|
|
|
|
Re: Cairo [message #19755 is a reply to message #19754] |
Tue, 13 January 2009 17:53   |
 |
mirek
Messages: 14256 Registered: November 2005
|
Ultimate Member |
|
|
The problem is that you cannot apply (at least in current SDraw) the path transformation during path definition. And you had that Rotate after Move (Move starts path, any Fill or Stroke or Clip ends it).
Fixed:
void DoRect(SDraw &sw, double size)
{
if(size < 0.5)
return;
sw.Move(0, 0);
sw.Line(0, size);
sw.Line(size, size);
sw.Line(size, 0);
sw.Fill(Blue());
sw.Begin();
sw.Translate(0, size);
sw.Rotate(M_PI/4.);
DoRect(sw, size / M_SQRT2);
sw.End();
sw.Begin();
sw.Translate(size / 2, 1.5 * size);
sw.Rotate(-M_PI/4.);
DoRect(sw, size / M_SQRT2);
sw.End();
}
void DrawPythagorasTree(Size sz, SDraw *sw, Cairo *ca)
{
double size = 128;
if (sw)
{
sw->Begin();
sw->Translate(sz.cx / 2 - size / 2, sz.cy);
sw->Scale(1, -1);
DoRect(*sw, size);
sw->End();
}
Mirek
|
|
|
Re: Cairo [message #19756 is a reply to message #19755] |
Tue, 13 January 2009 17:55   |
 |
mirek
Messages: 14256 Registered: November 2005
|
Ultimate Member |
|
|
Well, these preliminary results look promising:
TIMING Cairo lion : 156.00 ms - 7.80 ms (156.00 ms / 20 ), min: 7.00 ms, max: 9.00 ms, nesting: 1 - 20
TIMING Cairo tree : 2.85 s - 142.70 ms ( 2.85 s / 20 ), min: 139.00 ms, max: 146.00 ms, nesting: 1 - 20
TIMING AGGUPP lion : 46.00 ms - 2.30 ms (46.00 ms / 20 ), min: 1.00 ms, max: 3.00 ms, nesting: 1 - 20
TIMING AGGUPP tree : 627.00 ms - 31.35 ms (627.00 ms / 20 ), min: 29.00 ms, max: 34.00 ms, nesting: 1 - 20
I have heard AGG is fast. It really is 
Mirek
EDIT: I have noticed that in tree, I left AGG to go up to size 0.5, so it was at disadvantage. With the same requirements, it is much faster than that.. (above numbers are updated to size < 1).
[Updated on: Tue, 13 January 2009 17:59] Report message to a moderator
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat May 03 22:23:04 CEST 2025
Total time taken to generate the page: 0.02978 seconds
|
|
|