// Prepare & Draw the axis and cube protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); viewMatrix = Matrix.CreateViewMatrix(r, phi, theta); modelMatrix = Matrix.Translate(position) * (Matrix.Rotate(rotation) * (Matrix.Scale(scale))); Prepare(cube.vb, modelMatrix); cube.Draw(e.Graphics, vb); Prepare(x_axis.vb, Matrix.Identity()); x_axis.Draw(e.Graphics, vb); Prepare(y_axis.vb, Matrix.Identity()); y_axis.Draw(e.Graphics, vb); Prepare(z_axis.vb, Matrix.Identity()); z_axis.Draw(e.Graphics, vb); label1.Text = "Scale: " + scale + " S/s"; label2.Text = "TransX: " + position.x + " Left/Right"; label3.Text = "TransY: " + position.y + " Up/Down"; label4.Text = "TransZ: " + position.z + " PgDn/PgUp"; label5.Text = "RotX: " + rotation.x + " x/X"; label6.Text = "RotY: " + rotation.y + " y/Y"; label7.Text = "RotZ: " + rotation.z + " z/Z"; label8.Text = "r: " + r + " r/R"; label9.Text = "d: " + d + " d/D"; label10.Text = "phi: " + phi + " p/P"; label11.Text = "theta: " + theta + " t/T"; label12.Text = "Phase: " + phase; }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); axisX.Draw(e.Graphics, ViewportTransformation(Width, Height, axisX.vectorBuffer)); axisY.Draw(e.Graphics, ViewportTransformation(Width, Height, axisY.vectorBuffer)); square.Draw(e.Graphics, ViewportTransformation(Width, Height, square.vectorBuffer)); squareTransformed.Draw(e.Graphics, ViewportTransformation(Width, Height, squareTransformed.vectorBuffer)); }
void GenRandomImg() { float[] x = new float[1280 * 720]; Random random = new Random(); for (int i = 0; i < x.Length; i++) { x[i] = random.Next(0, 255); } axis = new AxisX(x, 0, 255); pictureBox1.Image = axis.Draw(); Bitmap bmp = new Bitmap(1280, 720); var bitmap = bmp.LockBits( new Rectangle(0, 0, 1280, 720), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); Marshal.Copy(x.Select(s => (byte)s).ToArray(), 0, bitmap.Scan0, x.Length); bmp.UnlockBits(bitmap); pictureBox2.Image = bmp; }