Пример #1
0
 def generate():
     r, g, b = [random.randrange(16) for _ in xrange(3)]
     a = random.randrange(8)
     x, y = [random.randrange(256) for _ in xrange(2)]
     d = 1 << random.randrange(8)
     return Triangle(Vertex.generate(r, g, b, a, x, y, d)
                     for _ in xrange(3))
Пример #2
0
    def generate():
        """Generate a triangle.

        Generate the three vertices at a maximum distance d from a central
        point (x, y). This strategy yields a greater ratio of small triangles
        than does independent vertex generation.
        """
        r, g, b = [random.randrange(16) for _ in xrange(3)]
        a = random.randrange(8)
        x, y = [random.randrange(256) for _ in xrange(2)]
        d = 1 << random.randrange(8)
        return Triangle(Vertex.generate(r, g, b, a, x, y, d)
                        for _ in xrange(3))
Пример #3
0
 def read(f):
     return Triangle(Vertex.read(f) for _ in xrange(3))