How to fill a custom shape with color or texture?


Author
Message
Marius Bucur
Marius Bucur
Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)
Group: Forum Members
Posts: 12, Visits: 1
I am trying to fill a custom shape with color or a texture, but so far i have no luck. Basically my code look like this:

GraphicsPath graphicsPath = new GraphicsPath();

PointF[] points = new PointF[]
{
new PointF(0, 0),
new PointF(0, 20),
new PointF(20, 20),
new PointF(20, 0),
};
graphicsPath.AddPolygon(points);
//InitTextures();
NCompositeShape shape = new NCompositeShape();
shape.Primitives.AddChild(new NCustomPath(graphicsPath, PathType.OpenFigure));
shape.UpdateModelBounds();
//NImageFillStyle img = new NImageFillStyle(this.textures["bricks"] as Bitmap);
//img.TextureMappingStyle.MapMode = MapMode.RelativeToObject;
//shape.Style.FillStyle = img;
shape.Name = "Basic Wall";
shape.Text = "Basic Wall";


shape.Style.FillStyle = new NColorFillStyle(Color.AliceBlue);
shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(0, 0, 0x88));
Reply
Marius Bucur
Marius Bucur
Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)
Group: Forum Members
Posts: 12, Visits: 1
nvm, its solved. I should be using PathType.ClosedFigure in this line: shape.Primitives.AddChild(new NCustomPath(graphicsPath, PathType.OpenFigure));

But i have another question, is it possible to make a texture pattern repeat and not stretch when i resize the custom shape ?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search