Upload presentasi
Presentasi sedang didownload. Silahkan tunggu
Diterbitkan olehYenny Rachman Telah diubah "6 tahun yang lalu
1
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
COMPUTER GRAPHICS D10K-5C01 GK04a: Transformasi 2D Menggunakan C# Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
2
Proses Transformasi
3
Langkah Transformasi
4
Sistem Koordinat Graphics g = e.Graphics; Point A = new Point(0, 0); Point B = new Point(120, 80); g.DrawLine(Pens.Black, A, B);
5
Translasi Koordinat Graphics g = e.Graphics; g.TranslateTransform(50, 40); Point A = new Point(0, 0); Point B = new Point(120, 80); g.DrawLine(Pens.Black, A, B);
6
Ukuran Pen dan Satuan g.PageUnit = GraphicsUnit.Inch; g.DrawLine(Pens.Black, 0, 0, 2, 1);
7
Operasi Matriks pada C#
Before using the Matrix class in your applications, you need to add a reference to the System.Drawing.Drawing2D namespace. Matrix M1 = new Matrix(); Matrix M2 = new Matrix(2, 1, 3, 1, 0, 4); Matrix M3 = new Matrix(0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f);
8
Beberapa Properties Class Matrix
Elements IsIdentity InInvertible OffsetX OffsetY
9
Contoh 1 private void InvertMenu_Click(object sender, System.EventArgs e) { string str = "Original values: "; Matrix X = new Matrix(2, 1, 3, 1, 0, 4); for(int i=0; i<X.Elements.Length; i++) { str += X.Elements[i].ToString(); str += ", "; } str += "\n"; str += "Inverted values: "; X.Invert(); float[] pts = X.Elements; for(int i=0; i<pts.Length; i++) { str += pts[i].ToString(); str += ", "; } MessageBox.Show(str); }
10
Contoh 2 private void MultiplyMenu_Click(object sender, System.EventArgs e) { string str = null; Matrix X = new Matrix(2.0f, 1.0f, 3.0f, 1.0f, 0.0f, 4.0f); Matrix Y = new Matrix(0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f); X.Multiply(Y, MatrixOrder.Append); for(int i=0; i<X.Elements.Length; i++) { str += X.Elements[i].ToString(); str += ", "; } MessageBox.Show(str); }
11
Rotasi Pusat (50,50) private void rotasi_Click(object sender, System.EventArgs e) { Graphics g = this.CreateGraphics(); g.TranslateTransform(50,50); g.DrawLine(new Pen(Color.Green, 3), new Point(0, 0), new Point(200, 50)); g.RotateTransform(45); g.DrawLine(new Pen(Color.Yellow, 3), g.Dispose(); }
12
Rotasi
13
Pengantar Ingat kembali program menggambar titik
Buat program grafis yang mampu Menggambar objek grafis dalam GDI+ Melakukan transformasi terhadap objek grafis Translasi Rotasi Refleksi Scaling Shear
Presentasi serupa
© 2024 SlidePlayer.info Inc.
All rights reserved.