Kelvin Loke

Kelvin Loke

  • NA
  • 22
  • 0

Problem with LinearGradientBrush

Aug 30 2007 6:16 PM
Hi everyone, I´m having some problems with my code, the problem is I´m trying to paint some points in a Viewport, and this code only works if I paint points of each color. But what I need is this to work even if all the boxes are the same color, the problem is that the offset doesn´t work... can anyone help me? Thank you!!! Here´s the code: Point3D location = new Point3D(x, y, z); AddBox(mesh, location, // Location new Size3D(.02, .02, .02), // Size k // Color ); } LinearGradientBrush gradient = new LinearGradientBrush(); gradient.GradientStops.Add(new GradientStop(Colors.Red, 0.0)); gradient.GradientStops.Add(new GradientStop(Colors.Yellow, 0.5)); gradient.GradientStops.Add(new GradientStop(Colors.Blue, 0.75)); gradient.GradientStops.Add(new GradientStop(Colors.Green, 1.0)); Material material; material = new DiffuseMaterial(gradient); // constructs a DiffuseMaterial with the specified Brush property, in this case gradient GeometryModel3D geometry = new GeometryModel3D(mesh, material); //Creates a 3-D model comprised of a MeshGeometry3D and a Material. // This data won't change, so we can freeze it for a small perf win. geometry.Freeze(); model.Content = geometry; return model; }