def stars(): width = 800 height = 600 r = Render(width, height) def star(s, y, size): c = random.randint(0, 255) r.set_color(color(c, c, c)) if size == 1: r.point(x, y) elif size == 2: r.point(x, y) r.point(x + 1, y) r.point(x, y + 1) r.point(x + 1, y + 1) elif size == 3: r.point(x, y) r.point(x + 1, y) r.point(x, y + 1) r.point(x - 1, y) r.point(x, y - 1) for x in range(width - 4): for y in random(height - 4): if random.random() < 0.001: star(x + 2, y + 2, random.randint(1, 3)) r.display('out.bmp')
def diagonal(): width = 800 height = 600 r = Render(width, height) for x in range(width): for y in range(height): if x == y: r.point(x, y) r.display('out.bmp')
def static(): width = 800 height = 600 r = Render(width, height) for x in range(width): for y in range(height): if random.random() > 0.5: r.point(x, y) r.display('out.bmp')
def color_static(): width = 800 height = 600 r = Render(width, height) for x in range(width): for y in range(height): r.point( x, y, r.color(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))) r.display('out.bmp')
def square(): width = 800 height = 600 r = Render(width, height) padding = 10 square_w = width - padding square_h = height - padding for x in range(width): if (x > padding and x < square_w): r.point(x, square_h) r.point(x, padding) for y in range(height): if (y > padding and y < square_h): r.point(square_w, y) r.point(padding, y) r.display('out.bmp')
def cube(): r = Render(800,600) r.load('./models/cube.obj',(9,2),(40,40)) r.display() r.display('out.bmp')
def face(): r = Render(800,600) r.load('./models/face.obj',(25, 5, 0), (15, 15, 15)) r.display() r.display('out.bmp')
def single_line(): r = Render(800,600) r.line((15,32),(589,50),(0,0,0)) r.display('out.bmp')
def model(): r = Render(800, 600) t = Texture('./models/model.bmp') r.load('./models/model.obj', (1, 1, 1), (300, 300, 300), texture=t) r.display('out.bmp')
def car(): r = Render(800, 600) t = Texture('./models/car.bmp') r.load('./models/car.obj', (60, 20, 1), (5, 5, 5), texture=t) r.display('out.bmp')
def earth(): r = Render(800, 600) t = Texture('./models/earth.bmp') r.load('./models/earth.obj', (800, 600, 0), (0.5, 0.5, 1), texture=t) r.display('out.bmp')
def face(): r = Render(800, 600) t = Texture('./models/earth.bmp') r.load('./face.obj', (25, 5, 0), (15, 15, 15)) r.display('out.bmp')
from render import Render import obj as obj ren = Render() ren.glCreateWindow(800, 600) print('Elija el modelo a cargar:') print('1. Osos') print('2. Rostro') try: res = int(input()) if res == 1: ren.loadObj('./models/bears.obj', 9, 2, 40) ren.display('out') elif res == 2: ren.loadObj('./models/face.obj', translateX=25, translateY=8,scale=15) ren.display('out') else: print('Opcion invalida.') except e: print('Opcion invalida.')
def hand(): r = Render(800,600) r.load('./models/hand.obj',(25, 25, 0), (10, 10, 10)) r.display() r.display('out.bmp')
def bear(): r = Render(800,600) r.load('./models/bears.obj',(9,2),(40,40)) r.display() r.display('out.bmp')
def girl(): r = Render(800,600) r.load('./models/girl.obj',(0.5, 0, 0), (500, 500, 300)) r.display() r.display('out.bmp')
def figures(): r = Render(800,600) r.load('./models/figures.obj',(0, 0.5, 1), (100, 100, 100)) r.display() r.display('out.bmp')
size = random.random() / 4 r.load('./models/model.obj', [-i / 30, math.sin( (30 * i)) * 0.1, 0], [size, size, size], [0, 1.7, 1.1]) r.draw_arrays('TRIANGLES') """ We draw this creature using the brasaleo model to generate the weird creature using the shader fragment """ #Draw a brasaleo print("brasaleo") t = Texture('./models/fire2.bmp') r.active_texture = t r.active_light = norm(V3(10, 20, 0)) r.load('./models/brasaleo.obj', [-0.75, 0, 1], [0.02, 0.01, 0.01], [0, 0.7, 0]) r.active_shader = fragment r.draw_arrays('TRIANGLES') """ We draw an effect of reflection in the to simulate water, it change a liite bit the color, using a shader. """ water(r) r.display(out)
def car(): r = Render(800,600) r.load('./models/car.obj',(55, 55, 0), (5, 5, 5)) r.display() r.display('out.bmp')
def grass(): r = Render(800,600) r.load('./models/grass.obj',(9,2),(70,70)) r.display() r.display('out.bmp')
def house(): """ Draws lines from every corner """ r = Render(800, 600) #first rooftop for i in range(187): r.line((i + 98, 411), (i + 426, 599), (164, 0, 0)) #second rooftop for i in range(510): r.line((i + 285, 411), (468, 193), (204, 0, 0)) for i in range(330): r.line((288 + i, 412), (615, 599), (204, 0, 0)) for i in range(185): r.line((615, 599), (610 + i, 412), (204, 0, 0)) #wall where is the door for i in range(325): r.line((138, 168), (286, 411 - i), (186, 189, 182)) for i in range(147): r.line((138, 168), (139 + i, 410), (186, 189, 182)) for i in range(168): r.line((428, 241), (287, 241 + i), (186, 189, 182)) for i in range(142): r.line((429, 3), (287 + i, 240), (186, 189, 182)) for i in range(154): r.line((429, 3), (287, 86 + i), (186, 189, 182)) #door for i in range(176): r.line((238, 110), (322, 240 - i), (143, 89, 2)) for i in range(187): r.line((323, 240), (238, 111 + i), (143, 89, 2)) #wall of windows with shadow for i in range(-46, 46): r.line((469, 193), (429, 193 - i), (186, 189, 182)) for i in range(15): r.line((471, 184), (757, 385 - i), (186, 189, 182)) for i in range(90): r.line((757, 385), (471, 194 - i), (186, 189, 182)) for i in range(15): r.line((449, 170), (471, 195 - i), (186, 189, 182)) #wall of windows for i in range(177): r.line((429, 3), (756, 194 + i), (211, 215, 207)) for i in range(153): r.line((756, 371), (428, 3 + i), (211, 215, 207)) r.line((428, 4), (428, 242), (0, 0, 0)) #windows for i in range(101): r.line((531, 134), (656, 205 + i), (52, 101, 164)) for i in range(89): r.line((657, 305), (532, 134 + i), (52, 101, 164)) #shadow for windows for i in range(14): r.line((657, 305), (532, 222 + i), (32, 74, 135)) for i in range(14): r.line((533, 235), (657, 318 - i), (32, 74, 135)) #289 #205 r.display('out.bmp')
def single_point(): r = Render(800,600) r.point(100,100) r.display('out.bmp')
def hand(): r = Render(800, 600) r.load('./models/hand.obj', (9, 2), (70, 70)) r.display() r.display('out.bmp')