Beispiel #1
0
def Canvas(width, height, fill=tuples.Color(0.0, 0.0, 0.0)):
    """Canvas appears to be a 2-dimensional structure.

    For the pixels, we're going to refer to them by width (x), height (y)
    because it seems natural.  However when storing and accessing them,
    it makes sense to have them be height, width (y, x).
    """
    pixels = [[fill] * int(height) for count in range(int(width))]
    return _c(width, height, pixels)
Beispiel #2
0
def step_impl(context, r, g, b):
    assert tuples.t_eq(tuples.hadamard_product(context.c1, context.c2),
                       tuples.Color(r, g, b))
Beispiel #3
0
def step_impl(context, x, y, z):
    context.c2 = tuples.Color(x, y, z)
Beispiel #4
0
def step_impl(context, sc, r, g, b):
    assert tuples.t_eq(tuples.t_mul(context.c1, sc), tuples.Color(r, g, b))
Beispiel #5
0
def step_impl(context, r, g, b):
    assert tuples.t_eq(tuples.t_sub(context.c1, context.c2),
                       tuples.Color(r, g, b))
Beispiel #6
0
def step_impl(context, r, g, b):
    context.c3 = tuples.Color(r, g, b)
Beispiel #7
0
def step_impl(context, r, g, b):
    every_pixel = tuples.Color(r, g, b)
    assert False not in [
        tuples.t_eq(every_pixel, this_pixel)
        for this_pixel in itertools.chain(*context.c.pixels)
    ]