Example #1
0
def step_impl(context):
    context.c2 = Color(0, 0.5, 0)
Example #2
0
def step_impl(context):
    context.red = Color(1, 0, 0)
Example #3
0
def step_impl(context):
    context.c1 = Color(1.5, 0, 0)
Example #4
0
def step_impl(context):
    for x in range(context.c.width):
        for y in range(context.c.height):
            context.c.set_pixel(x, y, Color(1, 0.8, 0.6))
Example #5
0
def step_impl(context):
    for x in range(context.c.width):
        for y in range(context.c.height):
            assert context.c.get_pixel(x, y) == Color(0, 0, 0)
Example #6
0
def step_impl(context):
    context.c1 = Color(0.9, 0.6, 0.75)
Example #7
0
    wind: Vector

    def __init__(self, gravity: Vector, wind: Vector):
        self.gravity = gravity
        self.wind = wind


def tick(proj: Projectile, env: Environment):
    position = proj.position + proj.velocity
    velocity = proj.velocity + env.gravity + env.wind
    return Projectile(position, velocity)


start = Point(0, 1, 0)
velocity = Vector(1, 1.8, 0).normal * 11.25
p = Projectile(start, velocity)

gravity = Vector(0, -0.1, 0)
wind = Vector(-0.01, 0, 0)

e = Environment(gravity, wind)

c = Canvas(900, 550)
color = Color(1.0, 0, 0)

while p.position.y >= 0:
    c.set_pixel(int(p.position.x), 500 - int(p.position.y), color)
    p = tick(p, e)

print(c.ppm)
Example #8
0
def step_impl(context):
    context.c1 = Color(1, 0.2, 0.4)
Example #9
0
def step_impl(context):
    context.c2 = Color(0.9, 1, 0.1)
Example #10
0
def step_impl(context):
    context.c = Color(0.2, 0.3, 0.4)
Example #11
0
def step_impl(context):
    assert context.c * 2 == Color(0.4, 0.6, 0.8)
Example #12
0
def step_impl(context):
    assert context.c1 - context.c2 == Color(0.2, 0.5, 0.5)
Example #13
0
def step_impl(context):
    assert context.c1 + context.c2 == Color(1.6, 0.7, 1.0)
Example #14
0
def step_impl(context):
    context.c2 = Color(0.7, 0.1, 0.25)
Example #15
0
def step_impl(context):
    context.c3 = Color(-0.5, 0, 1)
Example #16
0
def step_impl(context):
    assert context.c1 * context.c2 == Color(0.9, 0.2, 0.04)
Example #17
0
 def __init__(self, width: int, height: int):
     self._canvas = [[Color() for j in range(width)] for i in range(height)]
Example #18
0
def step_impl(context):
    context.c = Color(-0.5, 0.4, 1.7)