Profile Picture

How to fill a custom shape with color or texture?

Posted By Marius Bucur 15 Years Ago
Author
Message
Ivo Milanov
Posted 15 Years Ago
View Quick Profile
Forum Member

Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)

Group: Forum Members
Last Active: 2 Months Ago
Posts: 35, Visits: 15
Check out this topic in the .NET Vision Documentation:

Framework > Presentation Layer > Graphics > Appearance Styles > Fill Styles > Texture Mapping Style

It basically outlines the possible ways in which a texture can be mapped. To make the image Tiled used this code:

NImageFillStyle imageFill = ...;
imageFill.TextureMappingStyle.MapLayout = MapLayout.Tiled;

Best regards,
Ivo

Marius Bucur
Posted 15 Years Ago
View Quick Profile
Junior Member

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
Last Active: 14 Years Ago
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 ?

Ivo Milanov
Posted 15 Years Ago
View Quick Profile
Forum Member

Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)

Group: Forum Members
Last Active: 2 Months Ago
Posts: 35, Visits: 15
Hi Marius,

The custom path you create must be marked as ClosedFigure if the diagram is to attempt to fill the path interior:

NCompositeShape shape = new NCompositeShape();
shape.Primitives.AddChild(new NCustomPath(graphicsPath, PathType.ClosedFigure));

Best regards,
Ivo

Marius Bucur
Posted 15 Years Ago
View Quick Profile
Junior Member

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
Last Active: 14 Years Ago
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));



Similar Topics


Reading This Topic