예제 #1
0
파일: 2d.py 프로젝트: salonigoyal2309/CG
def scal(win, Sx, Sy):
    win.close()
    win = poly.drawPolygon(coords, points)
    result = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
    T = [[Sx, 0, 0], [0, Sy, 0], [0, 0, 1]]
    for i in range(len(matrix)):
        for j in range(len(T[0])):
            for k in range(len(T)):
                result[i][j] += matrix[i][k] * T[k][j]

    temp = []
    for i in range(len(result)):
        k = (i + 1) % len(result)
        l = []
        l.append(result[i][0])
        l.append(result[i][1])
        l.append(result[k][0])
        l.append(result[k][1])
        temp.append(l)

    drawPolygon1(win, temp)
    return win
예제 #2
0
def rot(win, thita):
    win.close()
    win = poly.drawPolygon(coords, points)
    result = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]

    T = [[1, 0, 0], [0, 1, 0], [-x, -y, 1]]
    for i in range(len(matrix)):
        for j in range(len(T[0])):
            for k in range(len(T)):
                result[i][j] += matrix[i][k] * T[k][j]

    T = [[math.cos(thita), math.sin(thita), 0],
         [-math.sin(thita), math.cos(thita), 0], [0, 0, 1]]
    result1 = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]

    for i in range(len(result)):
        for j in range(len(T[0])):
            for k in range(len(T)):
                result1[i][j] += result[i][k] * T[k][j]

    T = [[1, 0, 0], [0, 1, 0], [x, y, 1]]
    result = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
    for i in range(len(result1)):
        for j in range(len(T[0])):
            for k in range(len(T)):
                result[i][j] += result1[i][k] * T[k][j]

    temp = []
    for i in range(len(result)):
        k = (i + 1) % len(result)
        l = []
        l.append(result[i][0])
        l.append(result[i][1])
        l.append(result[k][0])
        l.append(result[k][1])
        temp.append(l)

    drawPolygon1(win, temp)
    return win
예제 #3
0
#for i in range(0,x):
#crd=[]
#print("Enter coordinates of line",i)
#x0 = int(input())
#y0 = int(input())
#x1 = int(input())
#y1 = int(input())
#crd.append(x0)
#crd.append(y0)
#crd.append(x1)
#crd.append(y1)
#points.append(crd)

points = [[150, 150, 150, 200], [150, 200, 200, 200], [200, 200, 200, 150],
          [200, 150, 150, 150]]
win = poly.drawPolygon(coords, points)

clipper = [[150, 150], [150, 200], [200, 200], [200, 150]]
polygon = [[100, 150], [200, 250], [300, 200]]

for i in range(len(polygon)):
    k = (i + 1) % len(polygon)
    line1 = Line(Point(polygon[i][0], polygon[i][1]),
                 Point(polygon[k][0], polygon[k][1]))
    line1.setFill("white")
    line1.draw(win)

suther(polygon)

win.getMouse()