Pattern Objects
Objects of the IDLgrPattern class are used to fill objects of the IDLgrPolygon class. Pattern objects can create a solid fill (the default), a line fill (with control over the orientation, spacing, and thickness of the lines used), or a pattern fill (using a byte pattern you specify). Pattern objects do not have a color of their own; patterns take their color from the COLOR property of the polygon they fill.
Creating Pattern Objects
Specify a fill-pattern style when you call the IDLgrPattern::Init method. Set the argument to the Init method equal to zero to create a solid fill, equal to one to create a line pattern, or equal to two to use a bitmap byte array as the fill pattern. For example, the following statement creates a pattern object with a solid fill:
The following statement creates a pattern object with lines ten pixels apart, 5 pixels wide, at an angle of 30 degrees:
To create a pattern fill, specify a 32-by-4 byte array via the PATTERN property of the pattern object. The byte array you specify will be tiled over the area of the polygon to be filled. For example, the following statements create a pattern fill with a random speckle. The first statement creates a 32-by-4 byte array with random values ranging between 0 and 255. The second statement creates the pattern object.
See "IDLgrPattern" (IDL Reference Guide) for details on creating pattern objects.
Using Pattern Objects
To fill a polygon with the pattern specified by a pattern object, set the FILL_PATTERN property equal to the pattern object reference:
The following statements create a triangle and fills it with the random speckle pattern:
pattern = BYTE(RANDOMN(seed, 32, 4)*255) myPattern = OBJ_NEW('IDLgrPattern', 2, PATTERN=pattern) myView = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[0,0,10,10]) myModel = OBJ_NEW('IDLgrModel') myPolygon = OBJ_NEW('IDLgrPolygon', [4, 7, 3], [8, 6, 3],$ color=[255,0,255], fill_pattern=myPattern) myView->Add, myModel myModel->Add, myPolygon myWindow = OBJ_NEW('IDLgrWindow') myWindow->Draw, myView