60001021 MaterialImage and MaterialMatrix of PenStyle to be applied on Solid Areas in wire2D mode

Article 60001021
Type Wish
Product Engine
Date Added 12/3/2009 12:00:00 AM
Fixed (12/4/2009 12:00:00 AM)
Submitted by Rahul Singh

Summary

MaterialImage and MaterialMatrix of PenStyle to be applied on Solid Areas in wire2D mode.

Solution

This feature is added in 6017

Example: The following example attach a material image into a filled rectangle object:

               

vdImageDef imagedef = doc.Images.Add(@"C:\Documents and Settings\Administrator\Desktop\Temp\jblake.jpg"); // use an image here from your disk

vdRect curve = new vdRect();

curve.SetUnRegisterDocument(doc);

curve.setDocumentDefaults();

curve.InsertionPoint = new gPoint(-2, -2);

curve.Width = 5;

curve.Height = 1.2;

//curve.Rotation = Globals.HALF_PI / 2.0d;

//get the sample points in entity Coordinate System

gPoints pts = curve.GetSamplePoints(0, 0);

//get the bounding box in entity Coordinate System

Box box = pts.GetBox();

//Set the rectangle to be solid fill

curve.HatchProperties = new vdHatchProperties(VectorDraw.Professional.Constants.VdConstFill.VdFillModeSolid);

//select a new color for the rectangle whitch is used to fill the region

vdColor col = new vdColor(vdColor.ColorType.ByColor); col.SystemColor = Color.Blue;

//attach material image to the filled color.

col.MaterialImage = imagedef;

//select the material matrix used to tranform the texture image

Matrix mat = new Matrix();

//set the texture image scaling in order the texture bitmap to be 1 Drawing Unit width

mat.ScaleMatrix(1.0d, (double)imagedef.Height / (double)imagedef.Width, 1.0d);

//In order to stretch and fit the image in the rectangle use the following scale instead.

// mat.ScaleMatrix(box.Width, box.Height, 1.0d);

//Set the rotation 45 degrees in counterclockwise direction

//mat.RotateZMatrix(Globals.HALF_PI / 2.0d);

//set the origin of the texture to be LowerLeft corner of rectangle in rectangle Entitiy CS

mat.TranslateMatrix(box.Max );

//finally we set the Material matrix for the selected fill color.

col.MaterialMatrix = mat.GetInvertion();

curve.PenColor = col;

//finally add the entitity to ActiveLayout entities collection

doc.ActiveLayOut.Entities.AddItem(curve);

//update the drawing are of the rectangle

curve.Invalidate();

Send comments on this topic.