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()
obj = Circle(Point(x, y), R)
97
x, y – aylana markazi koordinatalari, R – aylana rdiusi.
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
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.
Do'stlaringiz bilan baham: |