Agg 20th Lesson Agg::ellipse Method Approximation_scale ()

Source: Internet
Author: User

Dedicated to: Either scenario is a compromise choice, and any alternative can achieve the same effect. And it all depends on how you think about positioning. Ask is learning, self-study is learning, but can stand on the shoulders of giants, you can see more clearly perhaps go farther.

Excerpt from: http://franko.github.io/agg-intro/vertex-source.html

In the previous sections we have seenagg::p ath_storageObject. While the This object was very flexible and can be used to describe all kind of geometric shapes there was a few other vertex s Ource primitive Types. Actually there is not so many of them and we'll just discuss theAgg::ellipseObject because it'll be also useful to illustrate some important idea.

TheAgg::ellipseDoes not share anything with aagg::p ath_storageIn term of C + + class hierarchy, all the they has in common are that they implement the basic methods of a vertex source. Wonder why the Ellipse object can is useful if you can describe it with aagg::p ath_storage. The answer is, this latter needs to store a fixed number of vertices that approximate the ellipse for all the possible Resolution of the image. The problem is so if you draw a small circle a few vertices can being enough but if the circle was big you were going to need A lot of vertices to has a decent approximation. We'll see this with anAgg::ellipseObject The number of points is adapted on the fly, and you just need theApproximation_scale ()Method. Actually theAgg::ellipsedoes not store all the coordinates of the vertices but generetes them on the fly when needed using the mathematical Equati Ons. As a side effect you'll have also a benefit in the term of memory usage because an Ellipse object would use a very small Amou NT of memory indipendently of the approximation level.

At this point we need to explain theApproximation_scale ()Method.Approximation_scale ()We need to go back to the coordinates specifications. The coordinates is actually given as double precision floating point number and they could or may not map directly to pixel Coordinates. For example we can map some logical coordinates ranging from 0 to 1 to an huge viewport of size 1280x1280. The problem at aAgg::ellipseObject does not know the mapping between logical coordinates and viewport coordinates. So, the idea was that and letAgg::ellipseAdjust correctly the level of approximation your should call the methodApproximation_scale ()and pass as an argument the ratio between the viewport coordinates and the logical coordinates. The example of the viewport of size 1280x1280 we would need to useApproximation_scale ()With a scale argument of 1280.

We'll see later that the Approximation_scale () are also important with some kind of transformation like Bézier c Urves that is supposed to generate smooth curves based on a few vertices and some mathematical equations.


Agg 20th Lesson Agg::ellipse Method Approximation_scale ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.