Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
This lecture presents a display model (the output part of a GUI), giving examples of use and fundamental notions such as screen coordinates, lines, and color. Some examples of shapes are Lines, Polygons, Axes, and Text. For more information, inviting you refer. | Chapter 12 A display model Bjarne Stroustrup www.stroustrup.com/Programming Abstract This lecture presents a display model (the output part of a GUI), giving examples of use and fundamental notions such as screen coordinates, lines, and color. Some examples of shapes are Lines, Polygons, Axes, and Text. Stroustrup/Programming Overview Why graphics? A graphics model Examples Stroustrup/Programming Why bother with graphics and GUI? It’s very common If you write conventional PC applications, you’ll have to do it It’s useful Instant feedback Graphing functions Displaying results It can illustrate some generally useful concepts and techniques Stroustrup/Programming Why bother with graphics and GUI? It can only be done well using some pretty neat language features Lots of good (small) code examples It can be non-trivial to “get” the key concepts So it’s worth teaching If we don’t show how it’s done, you might think it was “magic” Graphics is fun! Stroustrup/Programming Why | Chapter 12 A display model Bjarne Stroustrup www.stroustrup.com/Programming Abstract This lecture presents a display model (the output part of a GUI), giving examples of use and fundamental notions such as screen coordinates, lines, and color. Some examples of shapes are Lines, Polygons, Axes, and Text. Stroustrup/Programming Overview Why graphics? A graphics model Examples Stroustrup/Programming Why bother with graphics and GUI? It’s very common If you write conventional PC applications, you’ll have to do it It’s useful Instant feedback Graphing functions Displaying results It can illustrate some generally useful concepts and techniques Stroustrup/Programming Why bother with graphics and GUI? It can only be done well using some pretty neat language features Lots of good (small) code examples It can be non-trivial to “get” the key concepts So it’s worth teaching If we don’t show how it’s done, you might think it was “magic” Graphics is fun! Stroustrup/Programming Why Graphics/GUI? WYSIWYG What you see (in your code) is what you get (on your screen) Direct correspondence between concepts, code, and output Stroustrup/Programming Display model Objects (such as graphs) are “attached to” a window. The “display engine” invokes display commands (such as “draw line from x to y”) for the objects in a window Objects such as Square contain vectors of lines, text, etc. for the window to draw Shape Square “window” Display Engine attach() attach() draw() Stroustrup/Programming Display model An example illustrating the display model int main() { using namespace Graph_lib; // use our graphics interface library Point tl(100,200); // a point (obviously) Simple_window win(tl,600,400,"Canvas"); // make a simple window Polygon poly; // make a shape (a polygon, obviously) poly.add(Point(300,200)); // add three points to the polygon poly.add(Point(350,100)); poly.add(Point(400,200)); poly.set_color(Color::red); // make the polygon red (obviously) .