|
Drawing Polygons Edges + Gradient Color using DrawArea class |
Posted by Sal on Nov-11-2015 23:21 |
|
Hi Peter,
Q1: I was looking for a better way of drawing a series of partial segments over a complex Polygon area already been drawn, to change its line width (border size of polygon)
I would like do that all in one pass
Is there such thing ?
Looks like the issue has been addressed for some specific graph types, but not in a generic form at the DrawArea class level or its parent (I was looking at a Radar sample)
Still working with Polygons...
Q2: If there a way to apply gradient colors to the intended drawn polygon using the primitive class level methods in DrawArea class ?
Specifically, I would like the Polygon color shade to have a darker color as the (x, y) coordinates of the points inside the polygon get larger
Is there available any (C++) sample code to accomplish the above rendering ?
Thanks
Sal |
Re: Drawing Polygons Edges + Gradient Color using DrawArea class |
Posted by Peter Kwan on Nov-12-2015 04:34 |
|
Hi Sal,
Q1.
The suggested method to draw a polygon with a thick border is to consider the thick
border itself as a polygon.
You can probably imagine that a thick line is in fact a rectangle (which is a polygon). In
order words, drawing a filled rectangle is equivalent to drawing a thick line. The thick
border itself is also a polygon, in which drawing a filled polygon is equivalent to drawing
the thick border. Basically, you need to have a polygon of which its vertices are the
inside vertices and outside vertices of the border.
As an example, suppose you have a rectangle with the 4 vertices being (0,0), (0, 100),
(100, 100) and (100, 0). To draw a 10-pixel thick inner border (that is, the border is
inside the square), you can create another polygon with 8 vertices as follows:
(0, 0) (0, 100) (100, 100) (100, 0), (0, 0), (10, 10), (10, 90), (90, 90) (90, 10), (10,
10)
You can try to plot the above on a graph paper, and you can see it is in fact a polygon
that represents the thick border.
For your case, you would need to develop a method to compute the vertices of the thick
border and draw it as a polygon.
Note that in general, a polygon can self-intersect, loop back on itself, etc.. In this case,
it is ambiguous which region should be inside the polygon, and which region is outside the
polygon. There are several common rules. In ChartDirector, the odd-even winding rule is
used.
Q2.
You can use DrawArea.linearGradientColor to create a gradient color that various based
on (x, y) coordinates and use it to fill the polygon.
Hope this can help.
Regards
Peter Kwan |
Re: Drawing Polygons Edges + Gradient Color using DrawArea class |
Posted by Sal on Nov-13-2015 22:41 |
|
Hi Peter,
thanks for the reply |
|