architetto francesco fantoni <hva - hermanitos verdes architetti> wrote:
how does lib2geom interacts with text (pango) and images? could them be
managed as well? text can obviously be converted to paths (though it
would be nice if lib2geom itself tokk care of this), but how about
images?

well, it doesn't!

what it does is provide classes for shapes (paths, primitives) and some other useful elements when working with vectors (matrices, functions for calculating intersections, etc etc.)

so, our use for it would be to change our BezierPath class (and maybe the primitives) to work with the 2geom classes. My idea would be to subclass the 2geom Path, and from there add some more methods (e.g. BezierPath.contains(point)).

WRT text classes, i think we could leave them as they are; maybe determining its bounding rect using 2geom would be useful for calculating the text bounds. On the other hand, of course we can use 2geom for outlined text paths.

For images, maybe we could have a 2geom rect corresponding to its dimensions.

I hope i'm making sense here -- essentially, text and images remain a job for the renderer, not 2geom; however, it's probably useful if we save their bounding boxes as 2geom rects -- this would free us from having to use Cairo to determine path/object bounds, as we do now (and which is probably one of our bottlenecks.)

Regarding transforms, 2geom will help too, however i kinda wonder if they're using Cairo behind the scenes...

Il giorno mer, 13/05/2009 alle 15.34 +0100, ricardo lafuente ha scritto:
wow Stuart, thanks for all the great points; i'll just comment a bit and later i'll add them to our tracker for the path to 0.3.

Stuart Axon wrote:
I think the CORNER, CENTER transformation stuff should still be manageable, we 
just need to push/pop objects which handle this, not individual matrices.
true; the difference is just translating and applying the transform (CENTER), as opposed to applying the transform only (CORNER). most of this was made harder because of our hacky solution to get the path bounds (= dimensions and center). I think that's probably one of the bottlenecks, now that i think of it: to determine the path bounds, we're creating a new cairo context, drawing the object, measuring it and then deleting everything. This is total overkill, and something that should be made a lot more straightforward when we try doing it via 2geom (more on this below).

Do we still have to reverse the coordinates at the end ?  - I wonder if we 
could use cairo.scale (or similar) to setup the coordinates we need (maybe we 
can use this to flip them).
do we do this coordinate reversal? I can't recall where, to be honest...

...but maybe OT, this is an issue to be dealt with when DrawBot is to be implemented, since its coordinate system has the origin at the bottom-left corner. Not sure how easy it will be.

Definitely storing the intermediate matrices preferably in some native format 
(lib2geom?) makes the a lot of sense too.
yes, lib2geom has all we need for matrices. Does everything cairo.Matrix does from what i saw.

WRT refactoring -
I think it can definitely be made simpler.

External api:
A simple external api.

I'd imagine we'd be able to do:
from shoebot import bot, cairo_renderer

shoebot.run(botname, renderer= cairo_renderer)
cairo_frame = shoebot.next_frame()
great point, hadn't thought of this.
something this reminds me is how Processing handles the backend choice: you specify it in size(), as in

    size(1024, 768, OPENGL)

once we have more backends, this might be a way to go too. But your solution is great when not reading an external script and calling bot commands from python.


- Probably we should move a lot of the colour transformation methods out of 
data and into something like colorsystems.py
totally, as a matter of fact we should look into our file structure:
- gtkui contains both the windowed mode code (when you specify -w) as well as the IDE. These should definitely be separated. - the bot and canvas stuff should get out of the __init__.py file and be moved to something like a shoebot.core module. - libs should be importable through a module, e.g. 'from shoebot.libs import sbopencv' or something. Not sure if this is allowed already. - maybe breaking apart data.py would be in order -- separating primitives, paths, transforms and colors.

Strings vs references:
I think there are a few places we could use references instead of if 'somestring'
  pass
elif 'someotherstring'
  pass
yes! We ought to make a list of where this is happening.

Namespace stuff:
copyattrs seems to show up quite high in the profiling, I wonder if we could do 
this in a different way avoiding isinstance
(I wonder if we could also avoid setattr and getattr too)
good to know; it was something copied directly from Nodebox. Wondering if there's faster methods to do it. Anyway, it's a function that's called a *lot* of times, so it's bound to be abundant when looking at debug output.

This sort of thing can be avoided:
  if namespace['draw']:  ## from memory
We can check if it exists once in the bot at the beginning and add an empty 
stub if it doesn't.
good point

Window resizing stuff:
We should be able to resize the window (probably everything inside could just 
scale like nodebox(?))
yes, definitely; this would imply having a 'view' instead of the window replicating the Cairo context, so that scaling wouldn't change the final output. That would also allow for zooming, panning, etc.

We need to sort out size()
I don't know what nodebox does if you call it in the middle of a script, but I 
guess we would just reset the canvas to the new size... being able to do this 
might avoid some of the weirdness around here.
yeah -- it does have that issue with calling size() using variables instead of absolute values, but that's something we can warn against. but you're right, at the very least it should issue a warning and fail silently when called more than once.

:r

-- Sorry if this is a bit of a braindump, it's still in my head from playing 
with the code last night :)
... + hopefully I will get round to looking at some of these myself.


----- Original Message ----
From: francesco fantoni <[email protected]>
To: [email protected]
Sent: Tuesday, May 12, 2009 1:50:57 PM
Subject: Re: [shoebot-devel] why Shoebot can be slow, and a possible way out


i'm inclined to think that the bottleneck is on how we handle the transforms -- there's a lot of stuff being calculated and re-calculated
I thought the same. Each graphical object comes with its copy of the
transformations' chain up to the moment of its creation, and at
rendering time we're forced to go through a long chain of
transformations over and over for each object.
It would be faster to store a resulting matrix as state-attribute of the
grobs, calculating it only once and updating it whenever a
transformation command is parsed, but I'm afraid that is possibile only
for CORNER mode transformations I think, as the CENTER mode depends on
each object's coordinates.
I suppose you could calculate the resulting matrix for the CORNER mode
transformations and then "add" the CENTER mode ones on a per-object
basis, but the push-pop loops could really make it impossible to manage
and I suppose the order of application of each transformation could
matter as well, though I'm not sure...

Just for the records- the numpy variant is here:

http://freehg.org/u/hva/shoebot-affine/



on the bright side: after working some more on the 2geom bindings, they're really close to usable. Some more testing, and maybe we can start using 2geom in shoebot.



refactored transforms. I tried to clean and optimize the code, it seems a bit faster now, but still slower than nodebox. waiting for a complete rewrite (with lib2geom?)
I've found an affine transformations library using numpy and released
under BSD license, maybe i will try it.
francesco

------------------------------------------------------------------------

_______________________________________________
Shoebot-devel mailing list
[email protected]
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
_______________________________________________
Shoebot-devel mailing list
[email protected]
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
_______________________________________________
Shoebot-devel mailing list
[email protected]
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net

_______________________________________________
Shoebot-devel mailing list
[email protected]
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net



_______________________________________________
Shoebot-devel mailing list
[email protected]
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
  • Re... architetto francesco fantoni <hva - hermanitos verdes architetti>
    • ... Stuart Axon
      • ... Stuart Axon
      • ... architetto francesco fantoni <hva - hermanitos verdes architetti>
        • ... Stuart Axon
        • ... ricardo lafuente
          • ... francesco fantoni
          • ... Stuart Axon
          • ... ricardo lafuente
          • ... architetto francesco fantoni <hva - hermanitos verdes architetti>
          • ... ricardo lafuente
          • ... francesco fantoni
          • ... ricardo lafuente

Reply via email to