|
|
|
|
4
|
![main2.png](images/main2.png)
|
4
|
![main2.png](images/main2.png)
|
5
|
![main3.png](images/main3-small.png)
|
5
|
![main3.png](images/main3-small.png)
|
6
|
|
6
|
|
7
|
-[Verano 2016- Tatiana - Ive]
|
|
|
|
|
7
|
+[Verano 2016- Tatiana - Ive - Tatiana]
|
8
|
|
8
|
|
9
|
Recursion is a technique that is commonly used in programming. With this technique, problems are done by solving similar problems but for smaller cases. We can construct sets of objects or tasks using *recursive rules* and *initial values*. *Recursive functions* are functions that are self-invoking, using smaller sets or elements each time, until reaching a point where an initial value is used instead of self-invoking. In this laboratory experience, you will implement some tools to draw and practice the use of recursive functions to fill with color some figures.
|
9
|
Recursion is a technique that is commonly used in programming. With this technique, problems are done by solving similar problems but for smaller cases. We can construct sets of objects or tasks using *recursive rules* and *initial values*. *Recursive functions* are functions that are self-invoking, using smaller sets or elements each time, until reaching a point where an initial value is used instead of self-invoking. In this laboratory experience, you will implement some tools to draw and practice the use of recursive functions to fill with color some figures.
|
10
|
|
10
|
|
|
|
|
|
48
|
---
|
48
|
---
|
49
|
|
49
|
|
50
|
|
50
|
|
51
|
-## `Qt` Coordinates:
|
|
|
|
|
51
|
+## `Qt` Coordinates
|
52
|
|
52
|
|
53
|
* The coordinate system in `Qt` works a bit differently, as it is shown in Figure 1. The entries go from left to right, from 0 to the maximum width, and from top to bottom, from 0 to the maximum height.
|
53
|
* The coordinate system in `Qt` works a bit differently, as it is shown in Figure 1. The entries go from left to right, from 0 to the maximum width, and from top to bottom, from 0 to the maximum height.
|
54
|
|
54
|
|
|
|
|
|
97
|
|
97
|
|
98
|
## Laboratory Session:
|
98
|
## Laboratory Session:
|
99
|
|
99
|
|
100
|
-### Exercise 1: Implement the Functions that Operate the Buttons for Drawing Lines
|
|
|
|
|
100
|
+### Exercise 1 - Implement the Functions that Operate the Buttons for Drawing Lines
|
101
|
|
101
|
|
102
|
####Instructions
|
102
|
####Instructions
|
103
|
|
103
|
|
|
|
|
|
165
|
**Figure 5** - (a) A drawing with a white background and red dots. (b) When the user clicks on the right diagonal line button (`DiagonalRight`) and clicks the cell shown, (c) a right diagonal line that expands towards the top to the right and towards the bottom to the left of the cell clicked is drawn, until it finds a cell with a different color from the color of the background.
|
165
|
**Figure 5** - (a) A drawing with a white background and red dots. (b) When the user clicks on the right diagonal line button (`DiagonalRight`) and clicks the cell shown, (c) a right diagonal line that expands towards the top to the right and towards the bottom to the left of the cell clicked is drawn, until it finds a cell with a different color from the color of the background.
|
166
|
|
166
|
|
167
|
|
167
|
|
168
|
-### Exercise 2: Implement the Functions that Operate the Buttons for Drawing Squares, Triangles and Circles.
|
|
|
|
|
168
|
+### Exercise 2 - Implement the Functions that Operate the Buttons for Drawing Squares, Triangles and Circles.
|
169
|
|
169
|
|
170
|
Now, you will implement the functionality to draw squares, circles and triangles. The **size** of the figure drawn will depend on the size selected on sliding bar in the interface.
|
170
|
Now, you will implement the functionality to draw squares, circles and triangles. The **size** of the figure drawn will depend on the size selected on sliding bar in the interface.
|
171
|
|
171
|
|
|
|
|
|
227
|
|
227
|
|
228
|
|
228
|
|
229
|
|
229
|
|
230
|
-### Exercise 3: Implement the Function that Fills the Figures using Recursion.
|
|
|
|
|
230
|
+### Exercise 3 - Implement the Function that Fills the Figures using Recursion.
|
231
|
|
231
|
|
232
|
In this exercise you will implement the functionality to fill the color of the figures.One of the more convinient ways to express the algorithm to fill the figures is using recursion. A basic recursive algorithm (but it’s pretty weak) is found in Wikipedia:
|
232
|
In this exercise you will implement the functionality to fill the color of the figures.One of the more convinient ways to express the algorithm to fill the figures is using recursion. A basic recursive algorithm (but it’s pretty weak) is found in Wikipedia:
|
233
|
|
233
|
|
|
|
|
|
267
|
|
267
|
|
268
|
---
|
268
|
---
|
269
|
|
269
|
|
270
|
-##References
|
|
|
|
|
270
|
+## References
|
271
|
|
271
|
|
272
|
[1] Alyce Brady and Pamela Cutter, http://nifty.stanford.edu/2005/GridPlotter/
|
272
|
[1] Alyce Brady and Pamela Cutter, http://nifty.stanford.edu/2005/GridPlotter/
|
273
|
|
273
|
|