gradient代码

> Actually, the gradient function determines only the shape of the gradient,
but
> not its orientation or position. To change the position and/or angle use
the
> affine matrix. For example, if you have a line segment x1,y1,x2,y2 and
want to
> set a linear gradient from (x1,y1) to (x2,y2) use the following:
>
> d1 = 0;
> d2 = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)); // distance
> agg::affine_matrix mtx;
> mtx *= agg::rotation_matrix(atan2(y2-y1, x2-x1));
> mtx *= agg::translation_matrix(x1, y1);
> mtx.invert();
>
> agg::gradient_x grad;
> gradient_span_gen span_gen(span_alloc, inter, grad, colors, d1, d2);
>
> Why you should invert the matrix is explained here (the same thing as for
> images):
>http://sourceforge.net/mailarchive/forum.php?thread_id=3502542&forum_id=32853


你可能感兴趣的:(代码,agg)