Finish triangle code and add triangle example to app

This commit is contained in:
2026-07-28 15:32:39 -05:00
parent c8efc0f586
commit 5aa66f343f
2 changed files with 19 additions and 5 deletions
+12 -2
View File
@@ -18,8 +18,18 @@ namespace Raster3D.App
public override void exec(Engine.Engine engine)
{
Line line = new Line(new Vec2D(0, 30), new Vec2D(30,60), engine);
line._Draw();
Vec2D[] points = new Vec2D[3];
points[0] = new Vec2D(32, 32);
points[1] = new Vec2D(64, 32);
points[2] = new Vec2D(64, 64);
rgb[] colors = new rgb[3];
colors[0] = new rgb(1.0f, 0.0f, 0.0f); // red
colors[1] = new rgb(0.0f, 1.0f, 0.0f); // green
colors[2] = new rgb(0.0f, 0.0f, 1.0f); // blue
Triangle triangle = new Triangle(points, colors, engine);
triangle._Draw();
}
}
}
+7 -3
View File
@@ -26,9 +26,13 @@ namespace Raster3D.Engine.Objects
public void _Draw()
{
children.Append(new Line(_positions[0], _positions[1], _clrs[0], _engine));
children.Append(new Line(_positions[1], _positions[2], _clrs[1], _engine));
children.Append(new Line(_positions[2], _positions[1], _clrs[2], _engine));
children[0] = (new Line(_positions[0], _positions[1], _clrs[0], _engine));
children[1] = (new Line(_positions[1], _positions[2], _clrs[1], _engine));
children[2] = (new Line(_positions[2], _positions[0], _clrs[2], _engine));
foreach (var child in children)
{
child._Draw();
}
}
public void _Free()