DR Array to polygon

4D - Documentation   Français   English   German   4D Draw 2004, Command Theme List   4D Draw 2004, Command Alphabetical List   Back   Previous   Next

version 6.0


DR Array to polygon (area; arrayH; arrayV) Longint

ParameterTypeDescription
areaLongint4D Draw area
arrayHNumeric arrayArray of horizontal values for vertices
arrayVNumeric arrayArray of vertical values for vertices
Function resultLongintObject ID

Description

The command DR Array to polygon creates a new polygon in area based on the arrays arrayH and arrayV and returns the new object's ID.

arrayH and arrayV describe the position of each polygon vertex. The two arrays can be of type Real, Longint, or Integer, and are specified in base units. Use the DR ARRAY SCALE TO BASE command to convert an array of scale units to base units. Each array must have at least three elements for the polygon to be successfully created. If the arrays are not the same size, the erroneous elements are ignored. To create a closed polygon, the last value in each array must match the first value.

Examples

(1) The following example is the converse of the example used for DR POLYGON TO ARRAY. It fills two arrays from a selection of records and then, if the arrays have at least 3 elements, it creates a polygon using the arrays.

   ARRAY REAL(ArrayH;0)
      `Declare the arrays
   ARRAY REAL(ArrayV;0)
   SELECTION TO ARRAY ([Polygon]FieldH;ArrayH;[Polygon]FieldV;ArrayV)
      `Fill the arrays
   If (Size of array (ArrayH) >= 3)
         `If the arrays have enough elements
      $New := DR Array to polygon (Area;ArrayH;ArrayV)
         `Create the polygon
   End if

(2) The following example is the object method for a button on a form that contains Area. It asks the user for a number and then creates a polygon using the entered number of vertices.

   $x := Num (Request ("How many vertices?"))
      `Ask how many vertices
   If (OK = 1)
         `If they OK the request
      DR SET ORIGIN (Area;2;2;0)
         `Set the origin to 2, 2.
      ARRAY REAL (ArrayH;$x)
         `Declare the arrays
      ARRAY REAL (ArrayV;$x)
      For ($i;1;$x)
            `Fill the arrays
         ArrayH{$i} := Sin ($i)
         ArrayV{$i} := Cos ($i)
      End for 
      $New := DR Array to polygon (Area;ArrayH;ArrayV)
         `Creates a polygon
   End if

See Also

DR GET POLYGON VERTEX, DR POLYGON TO ARRAY.


4D - Documentation   Français   English   German   4D Draw 2004, Command Theme List   4D Draw 2004, Command Alphabetical List   Back   Previous   Next