def model(): """ Draws a face, now 30% less cute """ r = Render(800, 600) r.load('./models/model.obj', (3, 3, 0), (200, 200, 15)) r.display('out.bmp')
def square(): """ Draws a square (to test correct dimensions) """ width = 800 height = 600 r = Render(width, height) padding = 10 square_w = width - padding square_h = height - padding # horizontal lines for x in range(width): if (x > padding and x < square_w): r.point(x, square_h) r.point(x, padding) # vertical lines 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 face(): """ Draws a cute face, now 30% less creepy! """ r = Render(800, 600) r.load('./models/face.obj', (25, 5, 0), (15, 15, 15)) r.display('out.bmp')
def cube(): """ Draws a cube at an angle so it is more interesting """ r = Render(800, 600) r.load('./models/cube2.obj', (4, 3, 3), (100, 100, 100)) r.display('out.bmp')
def figures(): """ Draws some simple shapes, to test z indexing """ r = Render(800, 600) r.load('./models/cubespherecone.obj', (0, 1, 1), (100, 100, 100)) r.display('out.bmp')
def figures(): """ Draws a cute face, now 30% less creepy! """ r = Render(800, 600) r.load('./models/figures.obj', (3, 1, 1), (100, 100, 100)) r.display('out.bmp')
def natsuki(): """ Draws natsuki from ddlc, because we can now """ r = Render(800, 600) r.load('./models/natsuki.obj', (0.5, 0, 0), (500, 500, 300)) r.display('out.bmp')
def multi_line(): """ Draws lines from every corner """ r = Render(800, 600) r.line((10, 10), (510, 10)) r.line((10, 10), (462, 191)) r.line((10, 10), (354, 354)) r.line((10, 10), (191, 462)) r.line((10, 10), (10, 510)) r.line((790, 590), (790, 90)) r.line((790, 590), (609, 138)) r.line((790, 590), (446, 246)) r.line((790, 590), (338, 409)) r.line((790, 590), (290, 590)) r.line((10, 590), (510, 590)) r.line((10, 590), (462, 409)) r.line((10, 590), (354, 246)) r.line((10, 590), (191, 138)) r.line((10, 590), (10, 90)) r.line((790, 10), (790, 510)) r.line((790, 10), (609, 462)) r.line((790, 10), (446, 354)) r.line((790, 10), (338, 191)) r.line((790, 10), (290, 10)) r.display('out.bmp')
def single_line(): """ Draws a single line in the screen (lower left corner) """ r = Render(800, 600) r.line((10, 10), (510, 10)) r.display('out.bmp')
def single_point(): """ Draws a single point in the screen (upper left corner) """ r = Render(800, 600) r.point(10, 590) r.display('out.bmp')
def simple_cube(): """ Draws a cube, but an orthogonal cube, so a square """ r = Render(800, 600) r.load('./models/cube.obj', (4, 3), (100, 100)) # r.display() r.display('out.bmp')
def face(): """ Draws a cute face, but in wireframe it just looks creepy """ r = Render(800, 600) r.load('./models/face.obj', (25, 5), (15, 15)) r.display() r.display('out.bmp')
def bears(): """ Draws some bears on top of each other """ r = Render(800, 600) r.load('./models/bears.obj', (9, 2), (40, 40)) # r.display() r.display('out.bmp')
def model(): """ Draws a cube at an angle so it is more interesting """ 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 earth(): """ Draws planet earth, racism free """ 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 model(): """ Draws a cube at an angle so it is more interesting """ r = Render(800, 600) t = Texture('./models/model.bmp') r.active_texture = t r.load('./models/model.obj', (1, 1, 1), (300, 300, 300)) r.draw_arrays('TRIANGLES') r.display('out.bmp')
def diagonal(): """ Draws a perfectly diagonal line """ width = 800 height = 600 r = Render(width, height) # very inefficient for x in range(width): for y in range(height): if x == y: r.point(x, y) r.display('out.bmp')
def static(): """ Draws static noise in B/W """ width = 800 height = 600 r = Render(width, height) # very inefficient for x in range(width): for y in range(height): if random.random() > 0.5: # 50/50 chance r.point(x, y) r.display('out.bmp')
def isometric_cube(): """ Draws a isometric cube """ r = Render(600, 600) r.line((200, 200), (287, 250)) r.line((200, 200), (113, 250)) r.line((200, 200), (200, 300)) r.line((287, 250), (287, 350)) r.line((113, 250), (113, 350)) r.line((200, 300), (287, 350)) r.line((200, 300), (113, 350)) r.line((287, 350), (200, 400)) r.line((113, 350), (200, 400)) r.display('out.bmp')
def triangle(): """ Draws triangles """ r = Render(200, 200) r.triangle( V2(10, 70), V2(50, 160), V2(70, 80), color(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))) r.triangle( V2(180, 50), V2(150, 1), V2(70, 180), color(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))) r.triangle( V2(180, 150), V2(120, 160), V2(130, 180), color(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))) r.display('out.bmp')
def color_static(): """ Draws static noise in color """ width = 800 height = 600 r = Render(width, height) # very inefficient for x in range(width): for y in range(height): r.point(x, y, color( random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) )) r.display('out.bmp')
def stars(): """ Randomly draws stars """ width = 800 height = 600 r = Render(width, height) def star(x, y, size): """ Draws a star. Size 1: small Size 2: medium Size 3: big """ c = random.randint(0, 255) r.set_color(color(c, c, c)) # 3 identical colors will always be gray if size == 1: r.point(x, y) elif size == 2: # 4 points r.point(x, y) r.point(x+1, y) r.point(x, y+1) r.point(x+1, y+1) elif size == 3: # 9 points r.point(x, y) r.point(x+1, y) r.point(x, y+1) r.point(x-1, y) r.point(x, y-1) # remove the corners # r.point(x+1, y+1) # r.point(x-1, y-1) # r.point(x-1, y+1) # r.point(x+1, y-1) # leaves a 2 pixel padding to avoid OOB for x in range(width - 4): for y in range(height - 4): if random.random() < 0.001: # 0.1% only 0.1 chance of actually rendering a star star(x + 2, y + 2, random.randint(1, 3)) r.display('out.bmp')
def cube(): """ Draws a cube """ r = Render(400, 400) r.line((100, 100), (200, 100)) r.line((100, 100), (100, 200)) r.line((200, 100), (200, 200)) r.line((100, 200), (200, 200)) r.line((150, 150), (250, 150)) r.line((150, 150), (150, 250)) r.line((250, 150), (250, 250)) r.line((150, 250), (250, 250)) r.line((100, 100), (150, 150)) r.line((100, 200), (150, 250)) r.line((200, 100), (250, 150)) r.line((200, 200), (250, 250)) r.display('out.bmp')
r.triangle(V2(70,320),V2(260,520),V2(190,250), color(192, 57, 43)) r.triangle(V2(260,520),V2(190,250),V2(380,450),color(192, 57, 43)) #techo fromtal r.triangle(V2(190,250),V2(380,450),V2(530,270),color(169, 50, 38)) #enfrente r.triangle(V2(190,130),V2(190,250),V2(310,139),color(169, 50, 38)) r.triangle(V2(530,150),V2(530,270),V2(410,144), color(169, 50, 38)) #--laterales r.triangle(V2(310,139),V2(310,335),V2(190,250),color(169, 50, 38)) r.triangle(V2(410,144),V2(410,340),V2(530,270),color(169, 50, 38)) #frontal r.triangle(V2(310,335),V2(310,235),V2(410,300),color(169, 50, 38)) r.triangle(V2(410,300),V2(410,240),V2(310,235),color(169, 50, 38)) #chimenea r.triangle(V2(310,490),V2(310,505),V2(296,500),color(146, 43, 33)) r.triangle(V2(310,505),V2(296,500),V2(296,515),color(146, 43, 33)) r.triangle(V2(296,500),V2(296,515),V2(325,483),color(169, 50, 38)) r.triangle(V2(296,515),V2(325,483),V2(325,510),color(169, 50, 38)) r.triangle(V2(310,505),V2(296,515),V2(325,510),color(192, 57, 43)) r.triangle(V2(296,515),V2(325,510),V2(311,520),color(192, 57, 43)) #fondo(r) contorno(r) pintar_casa(r) r.write('casita.bmp') r.display('casita.bmp')
def face(): r = Render(800, 600) r.load('./face.obj', (25, 5, 0), (15, 15, 15)) 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')
if x1 > x2: x1, x2 = x2, x1 y1, y2 = y2, y1 dy = abs(y2 - y1) dx = abs(x2 - x1) offset = 0 threshold = 1 * dx y = y1 for x in range(x1, x2): if steep: r.point(y, x) else: r.point(x, y) offset += dy * 2 if offset >= threshold: y += 1 if y1 < y2 else -1 threshold += 2 * dx #line(0, 0, 100, 100) line(165, 380, 185, 360) line(180, 330, 207, 345) line(233, 330, 230, 360) line(250, 380, 220, 385) line(205, 410, 193, 383) r.display()
def luigi(): """ Draws a cube at an angle so it is more interesting """ t = Texture("./luigiD.bmp") r.load("./Luigi_obj.obj", (110, 2, 1), (3.5, 3.5, 3.5), texture=t) def goomba(): """ Draws a cube at an angle so it is more interesting """ t = Texture("./goomba_grp.bmp") r.load("./goomba.obj", (110, 2, 1), (3.5, 3.5, 3.5), texture=t) def bmax(): t = Texture("./EyesWhite.bmp") r.load("./Bigmax_White_OBJ.obj", (150, 2, 1), (5, 5, 5), texture=t) luigi() print('luigi done') bmax() print('bmax done') #goomba() #print('goomba done') r.display('out.bmp')
def model(): r = Render(800, 600) r.load('./models/model.obj', (1, 1, 1), (300, 300, 300)) r.display('out.bmp')