Anti-Grain Geometry Contribution Packs (AGGCP)
by Milan Marusinec © 2007-2010
C/C++ AGG Contribution Pack - Gradients 2 (10.6.2010)


This AGG Contribution Pack (CP) extends existing set of gradient functions found in AGG 2.4 and later and is not a part of original source code distribution package, so you have to download and install this CP separately.

Following additional gradient functions are included:

Tensor product Color Mesh
(aka. PDF Shading Type 6 & 7)

Two approaches can be found in demo:

1) Color Interpolation - located in "tensor_product.cpp",
method render_with_interpolator()

Using this method, a mesh bezier surface is divided into the smaller bezier cells and color is interpolated along x and y axis.

2) Dedicated Rasterizer - located in "ShadingType7Rasterizer.h"
method render_with_rasterizer()

This method interpolates on y axis and computes pixel by pixel on x axis - for all curves on y axis. A finer detail can be achieved with this one.

I have found an underlying rasterizer in Cairo repository published under the LGPL/MPL licence, and for the purposes of using it in AGG only a small changes were necessary.

Note: Coons patch mesh can be rendered with the same code, just follow appropriate PDF specification for the additional internal 4 control points formula.

Download:

   AggCP-Gradients2.zip (source code)
   tensor_product.exe (compiled demo)

C/C++ AGG Contribution Pack - Gradients 1 (3.2.2008)



This AGG Contribution Pack extends existing set of gradient functions found in AGG 2.4 and later and is not a part of original source code distribution package, so you have to download and install this CP separately.

Following additional gradient functions are included:

gradient_contour

located in "agg_span_gradient_contour.h"

Creates color transitions from shape defined by an arbitrary (in fact any) path. It computes so called Distance Transform (DT) from image produced by only stroking the path, which is then the source of color level in the underlying gradient function.

Contour gradient can be used in two forms:

One is to define shape for contour different from shape of object being drawn. Second is to use the same shape for contour and for drawing (AutoContour).

gradient_conic_angle

located in "gradients_contour.cpp"

Assymetric conic gradient (also called angle) is the same as conic, but the ray of light with color transitions going counter clockwise travels whole circle instead of just half (as with conic).

Note: Implementation of this one is so tiny, it doesn't have it's own header file. If you want to use it, just copy and paste it from the demo file.

gradient_image

located in "agg_span_gradient_image.h"

Bitmap gradient is very similar to pattern fill, but works in the framework of gradient functions interfaces. Because of that all interpolator transformations from gradient span generator can be applied to this kind of fill (all affine transformations, perspective, bilinear & warp).

Note: This gradient function doesn't generates indexes for colors used.

When constructing the span_gradient object, the color function type is eg. agg::one_color_function<agg::rgba8> and instance of that color function is retrieved by calling special function of gradient_image class -> gradient_func.color_function().

See the "gradients_contour.cpp" demo for more details.

Download:

   AggCP-Gradients1.zip (source code)
   gradients_contour-vc.exe (compiled demo)

2007-2010 © Milan Marusinec alias Milano