Exemplo n.º 1
0
 def render_block(q, res, scale, quality):
     while not q.empty():
         block = q.get()
         res.put((block, map(list, mandel.build_set(block, scale, quality))))
     res.put(None)
Exemplo n.º 2
0
args = parser.parse_args()

s = socket.socket()
s.connect((args.server, args.port))

announce = interface.Message(interface.MSGT_ANNOUNCE, hostname=socket.gethostname())
announce.send(s)

state = 0 #announce sent

while 1:
    select.select([s], [], [])
    try:
        msg = interface.Message.load(s)
    except ValueError:
        print "Server stopped"
        break
    if msg.type == interface.MSGT_ANNOUNCE_RESP:
        state = 1 #anounce recieved
        print "Connected to {0}:{1}".format(args.server, args.port)
        print msg.content
    if msg.type == interface.MSGT_REQUEST:
        if state != 1:
            continue
        bounds, scale, quality = msg.block, msg.scale, msg.quality
        print "Got request for block {0}, running...".format(bounds),
        mandel_set = map(list, mandel.build_set(bounds, scale, quality))
        resp = interface.Message(interface.MSGT_RESPONSE, set=mandel_set, block=bounds)
        resp.send(s)
        print "done!"
Exemplo n.º 3
0
                pass

if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("--width", 
                        default=300,
                        type=int,
                        help="Width of the screen")
    parser.add_argument("--height",
                        default=200,
                        type=int,
                        help="Height of the screen")
    parser.add_argument("-q", "--quality",
                        default=64,
                        type=int,
                        help="Quality (number of iterations)")
    parser.add_argument("-o", "--output",
                        default="mandelbrot.png",
                        help="Output file")
    args = parser.parse_args()
    
    scales = mandel.scale((-2, 1, -1, 1), (args.width, args.height))
    s = mandel.build_set((-2, 1, -1, 1), scales, args.quality)
    
    im = Image.new("RGB", (args.width, args.height))
    fill_image(im, s, args.quality)
    with open(args.output, "w") as fo:
        im.save(fo)