Exemplo n.º 1
0
    def __init__(self, base_color, screen_size):
        ImageObject.__init__(self, base_color, screen_size)

        self.square_width = 0.25
        self.face_count = random.randint(2, 5)

        self.vertices = []
        self.squares = []

        lcorner_pos = [0.0, 0.0]
        for r in range(0, self.face_count+1):
            for c in range(0, self.face_count):
                self.vertices.append([lcorner_pos[0], lcorner_pos[1], 0.0])

                if r != self.face_count:
                    if self.color[0] <= 0.5:
                        color = self.color[0] + random.uniform(0.2, 1-self.color[0])
                    else:
                        color = self.color[0] - random.uniform(0.2, self.color[0])

                    self.squares.append(CheckerSquare(color=color, width=self.square_width, pos_x=lcorner_pos[0], pos_y=lcorner_pos[1]))

                lcorner_pos[0] += self.square_width

            self.vertices.append([lcorner_pos[0], lcorner_pos[1], 0.0])
            lcorner_pos[1] += self.square_width
            lcorner_pos[0] = 0.0
Exemplo n.º 2
0
    def __init__(self, base_color, screen_size):
        ImageObject.__init__(self, base_color, screen_size)
        self.vertices = [[0.0, 0.0, 0.25], [0.25, 0.0,
                                            0.25], [0.25, 0.25, 0.25],
                         [0.0, 0.25, 0.25], [0.0, 0.0, 0.0], [0.25, 0.0, 0.0],
                         [0.25, 0.25, 0.0], [0.0, 0.25, 0.0]]

        self.normals = [
            (0.0, 0.0, 1.0),  # front
            (0.0, 0.0, -1.0),  # back
            (1.0, 0.0, 0.0),  # right
            (-1.0, 0.0, 0.0),  # left
            (0.0, 1.0, 0.0),  # top
            (0.0, -1.0, 1.0)  # bottom
        ]

        self.vertex_indices = [
            (0, 1, 2, 3),  # front
            (4, 5, 6, 7),  # back
            (1, 5, 6, 2),  # right
            (0, 4, 7, 3),  # left
            (3, 2, 6, 7),  # top
            (0, 1, 5, 4)  # bottom
        ]

        self.tex_coords = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)]

        # tweak object shape
        height_adjust = (-1 * random.randint(0, 1)) * random.uniform(0.0, 0.20)
        width_adjust = (-1 * random.randint(0, 1)) * random.uniform(0.0, 0.20)
        depth_adjust = (-1 * random.randint(0, 1)) * random.uniform(0.0, 0.20)

        # height
        self.vertices[2][1] += height_adjust
        self.vertices[3][1] += height_adjust
        self.vertices[6][1] += height_adjust
        self.vertices[7][1] += height_adjust

        # width
        self.vertices[1][0] += width_adjust
        self.vertices[2][0] += width_adjust
        self.vertices[5][0] += width_adjust
        self.vertices[6][0] += width_adjust

        # depth
        self.vertices[0][2] += depth_adjust
        self.vertices[1][2] += depth_adjust
        self.vertices[2][2] += depth_adjust
        self.vertices[3][2] += depth_adjust

        # Color
        self.line_color = (0.0, 0.0, 0.0)
        if self.color[0] > 0.5:
            diff = (1.0 - self.color[0])
            self.line_color = (diff, diff, diff)
        else:
            diff = self.color[0]
            color = 1.0 - diff
            self.line_color = (color, color, color)
Exemplo n.º 3
0
    def __init__(self, base_color, screen_size):
        ImageObject.__init__(self, base_color, screen_size)
        self.vertices = [[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]]

        self.width = random.randint(1, 5)
        # tweak image shape
        self.vertices[0][0] += (-1 * random.randint(0, 1)) * random.uniform(
            0.0, 0.45)
        self.vertices[1][0] += (-1 * random.randint(0, 1)) * random.uniform(
            0.0, 0.45)
Exemplo n.º 4
0
    def __init__(self, base_color, screen_size):
        ImageObject.__init__(self, base_color, screen_size)
        self.vertices = [[-0.2, 0.0, 0.0], [0.0, 0.2, 0.0], [0.2, 0.0, 0.0]]
        self.tex_coords = [(0.0, 0.0), (1.0, 0.0), (0.5, 1.0)]

        # tweak image shape
        self.vertices[0][0] += (-1 * random.randint(0, 1)) * random.uniform(
            0.0, 0.15)
        self.vertices[1][1] += (-1 * random.randint(0, 1)) * random.uniform(
            0.0, 0.15)
        self.vertices[2][0] += (-1 * random.randint(0, 1)) * random.uniform(
            0.0, 0.15)
Exemplo n.º 5
0
    def __init__(self, base_color, screen_size):
        ImageObject.__init__(self, base_color, screen_size)
        self.a = 0.5
        self.b = 0.25

        self.a = random.uniform(0.1, 0.5)
        self.b = random.uniform(0.1, 0.5)

        # x^2/a^2 + y^2/b^2 = 1
        # x, y = a*cos(t), bsin(t) for 0<t<2pi
        self.vertices = []

        for t in np.arange(0.0, 2.0 * math.pi, 0.1):
            x, y = self.a * math.cos(t), self.b * math.sin(t)
            self.vertices.append([x, y, 0.0])
Exemplo n.º 6
0
    def __init__(self, base_color, screen_size):
        ImageObject.__init__(self, base_color, screen_size)
        self.vertices = [
            [0.0, 0.0, 0.0],  # star center
            [0.0, 0.5, 0.0],  # top
            [-0.5, 0.0, 0.0],  # left arm
            [0.5, 0.0, 0.0],  # right arm
            [-0.5, -0.5, 0.0],  # left leg
            [0.5, -0.5, 0.0]  # right leg
        ]

        self.width = random.randint(1, 5)
        # tweak image shape
        for i in range(1, len(self.vertices)):
            v1 = (-1 * random.randint(0, 1)) * random.uniform(0.0, 0.25)
            v2 = (-1 * random.randint(0, 1)) * random.uniform(0.0, 0.25)
            v3 = (-1 * random.randint(0, 1)) * random.uniform(0.0, 0.25)
            self.vertices[i] = [
                self.vertices[i][0] + v1, self.vertices[i][1] + v2,
                self.vertices[i][2] + v3
            ]
Exemplo n.º 7
0
    def __init__(self, base_color, screen_size):
        ImageObject.__init__(self, base_color, screen_size)
        self.vertex_pixels_calculated = True
        position = -10
        coord = 10
        self.vertices = [
            (coord, coord, position),
            (coord, -coord, position),
            (-coord, -coord, position),
            (-coord, coord, position)
        ]
        self.tex_coords = [
            (0.0, 0.0),
            (1.0, 0.0),
            (1.0, 1.0),
            (0.0, 1.0),
        ]
        self.normals = [
            (0, 0, 1.0)
        ]

        self.color = (0.5, 0.5, 0.5)