Jump to: navigation, search

Information about the group Translation of the wiki page Development/Tutorials/Qt4 Ruby Tutorial/Chapter 09.
Development/Tutorials/Qt4 Ruby Tutorial/Chapter 09Current message text
...Chapter 09/Page display title/ruРазработка/Руководства/Введение в Qt4 на Ruby/Глава 9
...t4 Ruby Tutorial/Chapter 09/1/ruTutorialBrowser/ru
...t4 Ruby Tutorial/Chapter 09/2/ruВведение в программирование на Qt<sup>®</sup>4 на языке Ruby
...t4 Ruby Tutorial/Chapter 09/3/ruПушка детям не игрушка
...t4 Ruby Tutorial/Chapter 09/4/ruПример 8: Готовься к битве
...t4 Ruby Tutorial/Chapter 09/5/ruПример 10: Гладкий как шёлк
...t4 Ruby Tutorial/Chapter 09/6/ru== Пушка детям не игрушка ==
...t4 Ruby Tutorial/Chapter 09/7/ru[[Image:Qt4_Ruby_Tutorial_Screenshot_9.png|center]]
...t4 Ruby Tutorial/Chapter 09/8/ruФайлы:
...t4 Ruby Tutorial/Chapter 09/9/ru=== Обзор ===
...4 Ruby Tutorial/Chapter 09/10/ruIn this example we become graphic by drawing a cute little blue cannon. Only cannon.rb differs from the previous chapter.
...4 Ruby Tutorial/Chapter 09/11/ru=== Построчный обзор программы ===
...4 Ruby Tutorial/Chapter 09/12/ruWe'll now start to use [ Qt::Painter] in earnest. We create a painter that operates on this widget.
...4 Ruby Tutorial/Chapter 09/13/ruThe edges of what [ Qt::Painter] draws are drawn using the pen. Here we set it to [ Qt::NoPen], meaning that there will be no special edge when we draw something.
...4 Ruby Tutorial/Chapter 09/14/ruWhen [ Qt::Painter] fills a rectangle, a circle, or whatever, it fills the shape using its brush. Here we set it to use a solid blue brush. (We could also use a pattern.) The blue brush will go all the way to the edges of the things we draw.
...4 Ruby Tutorial/Chapter 09/15/ruThe [ Qt::Painter::translate()] function translates the coordinate system of the [ Qt::Painter] (i.e., it moves it by an offset). Here we set the (0, 0) point to the bottom-left corner of the widget. The x and y directions remain unchanged, i.e., all the y coordinates inside the widget are now negative. (See [ The Coordinate System] for more information about Qt's coordinate system.)
...4 Ruby Tutorial/Chapter 09/16/ruThe [ Qt::Painter::drawPie()] function draws a pie shape inside the specified rectangle using a start angle and an arc length. The angles are specified in sixteenths of a degree. Zero degrees is at the 3 o'clock position. The drawing direction is counter-clockwise. Here we draw a quarter of a circle in the bottom-left corner of the widget. The pie is filled with blue and has no outline.
...4 Ruby Tutorial/Chapter 09/17/ruThe [ Qt::Painter::rotate()] function rotates the coordinate system of the [ Qt::Painter] around the origin. The rotation argument is given in degrees (not given in sixteenths of a degree as above) and clockwise. Here we rotate the coordinate system '''<tt>@currentAngle</tt>''' degrees counter-clockwise.
...4 Ruby Tutorial/Chapter 09/18/ruThe [ Qt::Painter::drawRect()] function draws the specified rectangle. Here we draw the barrel of the cannon.
...4 Ruby Tutorial/Chapter 09/19/ruIt can often be difficult to envision the resulting drawing when the coordinate system has been transformed (translated, rotated, scaled, or sheared) as above.
...4 Ruby Tutorial/Chapter 09/20/ruIn this case the coordinate system is first translated and then rotated. If the rectangle [ Qt::Rect].new(30, -5, 20, 10) had been drawn in the translated coordinate system, it would have looked like this:
...4 Ruby Tutorial/Chapter 09/21/ru[[Image:Qt4_Ruby_Tutorial_Screenshot_9-incorrect.png|center]]
...4 Ruby Tutorial/Chapter 09/22/ruNote that the rectangle is clipped by the border of the '''<tt>CannonField</tt>''' widget. When we rotate the coordinate system, for instance 60 degrees, the rectangle will be rotated around (0, 0), which is the bottom-left corner because we have translated the coordinate system. The result looks like this:
...4 Ruby Tutorial/Chapter 09/23/ru[[Image:Qt4_Ruby_Tutorial_Screenshot_9-correct.png|center]]
...4 Ruby Tutorial/Chapter 09/24/ru=== Запуск приложения ===
...4 Ruby Tutorial/Chapter 09/25/ruWhen the slider is operated the angle of the drawn cannon changes accordingly.
...4 Ruby Tutorial/Chapter 09/26/ru=== Exercises ===
Set a different pen instead of [ Qt::NoPen]. Set a patterned brush.
...4 Ruby Tutorial/Chapter 09/27/ru[[Category:Ruby/ru]]
NavigationShowing 28 messages.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal