Oliy va o’rta mahsus ta’lim vazirligi namangan davlat universiteti gulshod yunusova


Download 5.84 Mb.
bet25/40
Sana15.09.2023
Hajmi5.84 Mb.
#1678635
1   ...   21   22   23   24   25   26   27   28   ...   40
Bog'liq
python 1 qism дарслик Г.Юнусова (1)

Pythonda kesmani berish uchun funktsiya Line(birinchi uchi nuqtasi, ikkinchi uchi nuqtasi) qo’llaniladi
obj = Line(Point(x1, y1), Point(x2, y2))
x1, y1 – chiziq kesmasining boshi koordinatasi, x2, y2 – chiziq kesmasining ohirining koordinatasi.
Pythonda chiziqlar rangini berish uchun quyidagi buyruq qo’llaniladi obj.setOutline("цвет")
Пример программы на Pythonda dasturga misol u chiziqni grafik oynada akslantirdi.
from graphics import *
win = GraphWin("grafika uchun oyna", 400, 400) obj = Line(Point(50, 50), Point(350, 350)) obj.setOutline("blue")
obj.draw(win) win.getMouse() win.close()

Pythonda aylanani akslantirish uchun quyidagi opratordan foydalaniladi


obj = Circle(Point(x, y), R)
97
x, y – aylana markazi koordinatalari, R – aylana rdiusi.

Pythonda dasturga misol, u aylanani grafik oynada akslantiradi.


from graphics import *


win = GraphWin("Окно для графики", 400, 400) obj = Circle(Point(200, 200), 50)
obj.draw(win) win.getMouse() win.close()

Pythonda to’rtburchakni akslantirish uchun




protsedura obj = Rectangle(Point(x1, y1), Point(x2, y2)) qo’llaniladi
obj = Rectangle(Point(x1, y1), Point(x2, y2))
x1, y1 – to’rtburchakning yuqori chap burchagi koordinatalari, x2, y2 – to’rtburchakning yuqori o’ng burchagi koordinatalari

Pythonda to’rtburchakni grafik oynada akslantiruvchi dasturga misol


from graphics import *


win = GraphWin("Окно для графики", 300, 300) obj = Rectangle(Point(50, 50), Point(200, 250)) obj.draw(win)
win.getMouse() win.close()

98



Pythonda ellipsni akslantirish uchun quyidagi prosdura qo’llaniladi


obj = Oval(Point(x1, y1), Point(x2, y2))
x1, y1 – ellipsning birinchi fokusi koordinatalari, x2, y2 – ellipsning ikkinchi koordintalari.

Pythonda grafik oynada ekllipsni aks ettirish uchun.


from graphics import *


win = GraphWin("Окно для графики", 300, 300) obj = Oval(Point(100, 100), Point(250, 200)) obj.draw(win)
win.getMouse() win.close()

99

4.


Download 5.84 Mb.

Do'stlaringiz bilan baham:
1   ...   21   22   23   24   25   26   27   28   ...   40




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling