//// =========================================================================================================== //// Methods //// =========================================================================================================== protected override Canvas Render(CameraRenderOptions options) { var start = new Point(0, 1, 0); var velocity = new Vector(1, 1.8, 0).Normalize() * 11.25; var cannonball = new Projectile(start, velocity); // gravity is -0.1 unit/tick and wind is -0.01 unit/tick var gravity = new Vector(0, -0.1, 0); var wind = new Vector(-0.01, 0, 0); var environment = new Environment(gravity, wind); var color = Colors.Magenta; const int pixelBorderSize = 2; var canvas = new MutableCanvas(CanvasWidth, CanvasHeight); while (cannonball.Position.Y > 0) { cannonball = Tick(environment, cannonball); int pointX = (int)Math.Round(cannonball.Position.X); int pointY = (int)Math.Round(canvas.Height - cannonball.Position.Y); canvas.FillRect( top: pointY - pixelBorderSize, left: pointX - pixelBorderSize, bottom: pointY + pixelBorderSize, right: pointX + pixelBorderSize, color); } return(canvas.ToImmutable()); }
protected override Canvas Render(CameraRenderOptions options) { var canvas = new MutableCanvas(CanvasWidth, CanvasHeight); int centerX = canvas.Width / 2; int centerY = canvas.Height / 2; double clockRadius = Math.Min(canvas.Width * (3d / 8), canvas.Height * (3d / 8)); var color = Colors.Cyan; const int pixelBorderSize = 4; // The clock is oriented along the y axis, which means when looking at it face-on you're looking // towards the negative y axis and the clock face sits on the x-z plane. var twelve = new Point(0, 0, 1); const double rotationAngle = (2 * Math.PI) / 12; for (int hour = 0; hour < 12; hour++) { // Rotate the twelve point around the y axis. // Scale by the clock radius. // Translate to the center of the canvas. var transform = Matrix4x4.CreateRotationY(hour * rotationAngle); Point hourPoint = transform * twelve; int x = centerX + (int)Math.Round(hourPoint.X * clockRadius); int y = centerY - (int)Math.Round(hourPoint.Z * clockRadius); canvas.FillRect( top: y - pixelBorderSize, left: x - pixelBorderSize, bottom: y + pixelBorderSize, right: x + pixelBorderSize, color); } return(canvas.ToImmutable()); }