Lessons 59–60 · 2 lessons · N. I. Taylaqov (general editor), A. B. Akhmedov, M. D. Pardayeva, A. A. Abdug‘aniyev, U. M. Mirsanov. Informatics and Information Technologies, Grade 10, 1st edition. “Extremum-Press”, Tashkent, 2017
60
Practical lesson
Textbook: pp. 137–138
GoalDraws nested shapes, coordinate axes and coloured compositions with the Canvas; calculates the coordinates with a loop and formulas.
New words
nested shapes: shapes drawn one inside another around a common centre · ichma-ich shakllartick: a short mark on an axis · belgi (tick)bsClear: a brush style that does not fill the shape · bsClearcentre: the point around which shapes are placed · markaz
Explanation
In the practical lesson the coordinates of the drawing are calculated with a loop. 1) “Nested squares”: Image 200×200, centre (100, 100). Set the brush to bsClear and for i := 1 to 8 do Rectangle(100 - 12 * i, 100 - 12 * i, 100 + 12 * i, 100 + 12 * i); – the side of the i-th square is 24·i pixels, and that of the largest is 192. 2) “Coordinate axes”: MoveTo(10, 100); LineTo(190, 100); is the horizontal axis, MoveTo(100, 10); LineTo(100, 190); the vertical axis, ticks: for i := 1 to 9 do { x = 20·i, a segment from y = 96 to 104 }. 3) “Coloured circles”: 5 circles with a common centre, the colour of each given by the formula RGB(50·i, 0, 255 – 50·i). In each application calculate the most important numbers (the side of the largest square, the number of ticks) before drawing, write them down and compare them with the picture.
Worked examples
Squares: i = 1: Rectangle(88, 88, 112, 112), side 24; i = 3: Rectangle(64, 64, 136, 136), side 72; i = 8: Rectangle(4, 4, 196, 196), side 192. The sum of the sides of all 8 squares is 24·(1+2+…+8) = 24·36 = 864.
Ticks: x = 20, 40, …, 180 – nine of them; the distance between them is 20 pixels. For the 5 coloured circles: RGB(50, 0, 205), RGB(100, 0, 155), RGB(150, 0, 105), RGB(200, 0, 55), RGB(250, 0, 5): the red grows and the blue falls.
Class activity
“Picture and calculation”: a group makes 6 nested circles with its own formula and calculates the diameter of the largest circle and the sum of all diameters in advance.
Practice
1
What is the side of Rectangle(100-12*i, 100-12*i, 100+12*i, 100+12*i) at i = 4?
96
2
What is the sum of the sides of the 8 nested squares?
864
3
With RGB(50*i, 0, 255-50*i) at i = 3, what are the three values?
150, 0, 105
4
Why must the brush be bsClear for nested shapes?
A filled large shape would cover the smaller ones; with bsClear all are visible.