You are on page 1of 1

Kod źródłowy funkcji rysującej trójkąt Sierpińskiego:

1. void rysuj(int ax, int ay, int bx, int by, int cx, int cy, int st)
2. {
3. int abx,aby,acx,acy,bcx,bcy;
4. if (st>0)
5. {
6. bcx=(bx+cx)/2;
7. bcy=(by+cy)/2;
8. acx=(ax+cx)/2;
9. acy=(ay+cy)/2;
10. abx=(ax+bx)/2;
11. aby=(ay+by)/2;
12. triangle(screen, abx, aby, bcx, bcy, acx, acy, makecol(255,255,255));
13. rysuj(acx, acy, bcx, bcy, cx, cy, st-1);
14. rysuj(ax, ay, abx, aby, acx, acy, st-1);
15. rysuj(abx, aby, bx, by, bcx, bcy, st-1);
16. }
17. else
18. {
19. triangle(screen, ax, ay, bx, by, cx, cy, makecol(252,92,92));
20. rest(400);
21. }
22. };

Zaznacz na poniższym rysunku kolejność rysowanych trójkątów.

© Copyright by Nowa Era Sp. z o.o. 2015

You might also like