Method AddPolyHatch
- Namespace
- vdWebLibrary
- Assembly
- JsPropertiesExtractor.dll
AddPolyHatch(object[], object[], bool, object)
Adds a new vdPolyhatch in the document.
public object AddPolyHatch(object[] curves, object[] outlines, bool drawit, object entities)
Parameters
curvesobject[]An array of vdfigures that they will be hatched or an array of points.
outlinesobject[]Used for DrawBoundary property.An array of vdfigures or an array of points or null in order to use the outlines of the objects.
drawitboolDefines if the vdPolyhatch object will be drawn.
entitiesobjectThe entities collection where the polyhatch will be added. This can be the entities of layout or a block.
Returns
Examples
Example1:
In the first example we create a new polyline,arc,rectangle,circle and ellipse and then we will add them in the AddPolyhatch method.
We do not set any outlines so the outlines of the objects will be used.
var circle = vdcanvas.AddCircle([-3, -3, 0], 1, false);
var rect = vdcanvas.AddRect([-7, 6, 0], [-1, 10, 0], false);
var arc = vdcanvas.AddArc(vdgeo.newpoint(-20, 0, 0), 5, vdgeo.DegreesToRadians(0), vdgeo.DegreesToRadians(135), false);
var ellipse = vdcanvas.AddEllipse(vdgeo.newpoint(10, 10, 0), 10, 4, vdgeo.DegreesToRadians(90), vdgeo.DegreesToRadians(0), vdgeo.DegreesToRadians(360), false);
var vertexes = [vdgeo.newvertex(-2, -2, 0, 0), vdgeo.newvertex(2, 1, 0, 0), vdgeo.newvertex(5, 5, 0, 0), vdgeo.newvertex(2, 3, 0, 0)];
var pline = vdcanvas.AddPolyline(vertexes, false);
pline.SPlineFlag = 0;// standad polyline
pline.Flag = 1;// closed polyline.By default Flag = 0 which is not be closed.
vdcanvas.UpdateFig(pline);//update the figure in order to get the changes
var ph = vdcanvas.AddPolyHatch([arc, ellipse, circle, pline, rect], null, true);
ph.HatchProperties = vdcanvas.createNewHatchProperties("u20", vdConst.colorFromString("255,255,0,255"), vdConst.colorFromString("255,0,0,255"), 1.0, 0.0);
ph.HatchProperties.DrawBoundary = true;//By default is false so the boundary is not be drawn
vdcanvas.UpdateFig(ph);//update the figure in order to get the changes
vdcanvas.DrawEntity(ph);// draw the figure on the screen</code></pre>
Example2:
In the second example we create an array of eight points which represent two rectangles and then we will add them in the AddPolyhatch method.
We now set outlines the same points of the rectangles.
var a1, a2, a3, a4, b1, b2, b3, b4; //create the new eight variables
a1 = [0, 0, 0]; // set values for the first rectangle
a2 = [1, 0, 0];
a3 = [1, 1, 0];
a4 = [0, 1, 0];
b1 = [2, 0, 0]; // set values for the second rectangle
b2 = [3, 0, 0];
b3 = [3, 1, 0];
b4 = [2, 1, 0];
vdcanvas.SetActiveHatchProperties(vdcanvas.createNewHatchProperties('solid', vdConst.colorFromString("255,0,0"), vdConst.colorFromString("0,0,255")))//set active hatch properties
var ph = vdcanvas.AddPolyHatch([[a1, a2, a3, a4], [b1, b2, b3, b4]], [[a1, a2, a3, a4], [b1, b2, b3, b4]], true);
ph.HatchProperties.DrawBoundary = true; //By default is false so the boundary is not be drawn
vdcanvas.DrawEntity(ph); // draw the figure on the screen</code></pre>