from Task4 import Model from Task2 import MyImage from Task3 import Drawer import numpy as np model = Model() model.load('Test_alien.obj', (0, 3, 6)) model.setScale(-28, -28, 450, 700, False) poligons = model.getPoligons() points = model.getPoints() drawer = Drawer() image = MyImage(1000, 1000) for poligon in poligons: drawer.line4(points[poligon[0] - 1], points[poligon[1] - 1], image, (255, 255, 255)) drawer.line4(points[poligon[1] - 1], points[poligon[2] - 1], image, (255, 255, 255)) drawer.line4(points[poligon[2] - 1], points[poligon[0] - 1], image, (255, 255, 255)) image.save('Output/Task7_alien.jpg')
from Task4 import Model from Task2 import MyImage model = Model() model.load('Test_alien.obj', (0, 3, 6)) model.setScale(-28, -28, 450, 700, False) points = model.getPoints() image = MyImage(1000, 1000) for point in points: image.set(point[0], point[1], (255, 255, 255)) image.save('Output/Task5_alien.jpg')
image.set(x, y, (color, color, color)) image.setZ(x, y, z) drawer = Drawer() startPoint = (100, 100) finishPoints = np.zeros(13, dtype=tuple) for k in range(0, 13): alpha = 2 * math.pi * k / 13 x = int(100 + 95 * math.cos(alpha)) y = int(100 + 95 * math.sin(alpha)) finishPoints[k] = (x, y) image = MyImage(200, 200) for finishPoint in finishPoints: drawer.line1(startPoint, finishPoint, image, (255, 255, 255), 0.01) image.save('Output/Task3_Line1.jpg') image = MyImage(200, 200) for finishPoint in finishPoints: drawer.line1(startPoint, finishPoint, image, (255, 255, 255), 0.1) image.save('Output/Task3_Line2.jpg') image = MyImage(200, 200) for finishPoint in finishPoints: drawer.line2(startPoint, finishPoint, image, (255, 255, 255)) image.save('Output/Task3_Line3.jpg') image = MyImage(200, 200)
model.load('Test_alien.obj', (0, 3, 6)) model.setScale(-28, -28, 450, 700, False) #model.load('Test_rabbit.obj', (0, 3, 6)) #model.setScale(-8000, -8000, 500, 900, False) poligons = model.getPoligons() cos_lights = model.getCos_light() points = model.getPoints() model.rotate(0, 180, 0) drawer = Drawer() N = 1000 M = 1000 image = MyImage(N, M) k = 0 last_percent = 0 print('Percent compl:') for polygon in poligons: if cos_lights[k] < 0: drawer.drawPolygon( model, polygon, image, (int(-255 * cos_lights[k]), int( -255 * cos_lights[k]), int(-255 * cos_lights[k])), True) #drawer.line4(points[polygon[0] - 1], points[polygon[1] - 1], image, (255, 255, 255)) #drawer.line4(points[polygon[1] - 1], points[polygon[2] - 1], image, (255, 255, 255)) #drawer.line4(points[polygon[2] - 1], points[polygon[0] - 1], image, (255, 255, 255)) percent_compl = int(k / len(poligons) * 100) if percent_compl % 5 == 0 and last_percent != percent_compl:
model = Model() #model.load('Test_alien.obj', (0, 3, 6)) #model.setScale(-28, -28, 450, 700, False) model.load('Test_rabbit.obj', (0, 3, 6)) model.setScale(-8000, -8000, 500, 900, False) poligons = model.getPoligons() cos_lights = model.getCos_light() drawer = Drawer() N = 1000 M = 1000 image = MyImage(N, M) k = 0 last_percent = 0 print('Percent compl:') for polygon in poligons: if cos_lights[k] < 0: drawer.drawPolygon(model, polygon, image, (int(-255 * cos_lights[k]), int(-255 * cos_lights[k]), int(-255 * cos_lights[k])), True) percent_compl = int(k / len(poligons) * 100) if percent_compl % 5 == 0 and last_percent != percent_compl: print(percent_compl) last_percent = percent_compl k += 1 #image.save('Output/Task15_alien.jpg') image.save('Output/Task15_rabbit.jpg')