« Return to Thread: trans_affine question

Re: trans_affine question

by George Vlahakis :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.

Many thanks, I didn’t know about the bounding_rect functions!

 

From: Jim Barry [mailto:jim@...]
Sent: Thursday, March 12, 2009 1:29 PM
To: Anti-Grain Geometry
Subject: Re: [AGG] trans_affine question

 

In the first case, you are only considering the top-left and bottom-right points of the rectangle. In the second case, you correctly consider all four points. By the way, to calculate the bounding rectangle of a path, you can use agg::bounding_rect or agg::bounding_rect_single (see agg_bounding_rect.h).

 

- Jim

----- Original Message -----

From: georgios_vlachakis@...

Newsgroups: gmane.comp.graphics.agg

To: vector-agg-general@...

Sent: Wednesday, March 11, 2009 7:51 PM

Subject: trans_affine question

 

So here's a something I can't figure out while trying to pick a transformed path's bounds ....

                    agg::rect_i bounds_rect = glyph->bounds;
                    bounds_rect.normalize();
                    double x1, x2, y1, y2;

                    x1 = bounds_rect.x1;
                    y1 = bounds_rect.y1 + _offsetY;
                    x2 = bounds_rect.x2;
                    y2 = bounds_rect.y2 + _offsetY;

                    matrix.transform(&x1,&y1);
                    matrix.transform(&x2,&y2);

                    double minx = min(x1,x2);
                    double miny = min(y1,y2);
                    double maxx = max(x1,x2);
                    double maxy = max(y1,y2);

The above produces different mins and maxs on the y axis:

                    typedef conv_transform<path_storage, trans_affine>                    pathTransform;

                    double x1, x2, y1, y2, sx, sy;                  
                    agg::rect_i bounds_rect = glyph->bounds;
                    bounds_rect.normalize();

                    agg::path_storage bounds_path;

                    bounds_path.move_to( bounds_rect.x1, bounds_rect.y1 + _offsetY );
                    bounds_path.line_to( bounds_rect.x1, bounds_rect.y2 + _offsetY );
                    bounds_path.line_to( bounds_rect.x2, bounds_rect.y2 + _offsetY );
                    bounds_path.line_to( bounds_rect.x2, bounds_rect.y1 + _offsetY );
                    bounds_path.close_polygon();
                       
                    pathTransform transpath( bounds_path, matrix );
                                     
                    transpath.rewind(0);
                    unsigned subcmd = transpath.vertex(&sx,&sy);
                    minx=sx;
                    maxx=sx;
                    miny=sy;
                    maxy=sy;

                    while (!agg::is_close(subcmd))
                    {
                        minx = min(minx,sx);
                        maxx = max(maxx,sx);
                        miny = min(miny,sy);
                        maxy = max(maxy,sy);
                        subcmd = transpath.vertex(&sx,&sy);
                    }


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

 « Return to Thread: trans_affine question