170 likes | 182 Views
Learn about coordinate systems, drawing procedures, and the abstraction of drawing with graphics API. Explore paper size and location, vertex positions, and computer graphics solutions.
E N D
Chapter 3: Simple Graphics Program Chapter 3
We will learn • Review coordinate systems • Simplest drawing program • Graphics API drawing procedure • Abstraction of drawing with graphics API Chapter 3
Take a photograph • Paper: cut to right size • Position: place at right palce Chapter 3
Coordinate system • The origin • The X/Y Axes • Directions • Units on axes Chapter 3
Paper: size and location Chapter 3
Vertex Positions • Order of specification: • Va Vb Vc Vd • Clockwise vs Counterclockwise • Either is ok, but consistent ! • Choice of origin • Convenience! Chapter 3
Tutorial 3.1: Computer graphics solution Chapter 3
Tutorial 3.1: Frontend • Main application window and • Drawing Window Chapter 3
Tutorial 3.1: Backend programming • Main window (CTutorialDlg) • Has an instance of drawing window • At runtime: place the drawing window into the application window Chapter 3
Tutorial 3.1: Drawing Window • CGrfxWindowD3D … • A MFC CWnd object • Knows how to replace itself onto an application window • Allows D3D drawing (OnPaint()) … Chapter 3
GrfxWindow: OnPaint() function • Drawing … 4 steps … Chapter 3
GrfxWindow: Drawing … Chapter 3
Lesson learned: • Computer graphics: • Draws geometry: Render • Must measure and design before coding • Coordinate system • Choose a convenient system: • Origin, and units for measurement Chapter 3
Graphics API independent drawing Chapter 3
Graphics objects: Rectangle Chapter 3
Graphics objects: Circle • Center: (0,0) • Radius: r • If center at (xc,yc) • x = xc + r sin(θ) • y = yc + r cos(θ) Chapter 3
Circle: implementation Chapter 3