Beispiel #1
0
 def test_wshader_2_line_points_at_both_ends(self):
     s = Square()
     shader = WShader(bounding_box=s, line_count=2)
     point_list = [p for p in shader.path()]
     assert_equal(s.top_left_point, point_list[0])
     assert_equal(s.bottom_line.midpoint(), point_list[1])
     assert_equal(s.top_right_point, point_list[2])
Beispiel #2
0
 def test_points(self):
     s = Square(Point(0, 0), 2)
     top_right_distance = Point(1, 1).distance(s.top_right_point)
     assert_almost_equals(top_right_distance, 0)
     top_left_distance = Point(-1, 1).distance(s.top_left_point)
     assert_almost_equals(top_left_distance, 0)
     bottom_right_distance = Point(1, -1).distance(s.bottom_right_point)
     assert_almost_equals(bottom_right_distance, 0)
     bottom_left_distance = Point(-1, -1).distance(s.bottom_left_point)
     assert_almost_equals(bottom_left_distance, 0)
Beispiel #3
0
def lines(data, conf, shades=10.0):
    shades -= 1
    x, y, pixel, reverse = data
    pixel = 255 - pixel  # invert the color 255 is now black and 0 is white

    pixel = int(pixel * (shades / 255.0))
    pixel = pixel - 2
    if pixel < 0:
        pixel = 0

    if pixel:
        x = x * conf.pixel_size
        y = y * conf.pixel_size

        center = Point(x + conf.pixel_size / 2, y + conf.pixel_size / 2)
        bounding_box = Square(origin=center, size=conf.pixel_size)

        return WShader(bounding_box=bounding_box,
                       line_count=pixel,
                       reverse=reverse,
                       v_scale=0.8)
Beispiel #4
0
 def test_wshader_0_line(self):
     s = Square()
     shader = WShader(bounding_box=s, line_count=0)
     point_list = [p for p in shader.path()]
     assert_equal(len(point_list), 0)
Beispiel #5
0
 def test_wshader_v_scale(self):
     s = Square()
     shader = WShader(bounding_box=s, line_count=1, v_scale=2)
     point_list = [p for p in shader.path()]
     assert_equal(Point(-0.5, 1), point_list[0])
Beispiel #6
0
 def test_wshader_reversed(self):
     s = Square()
     shader = WShader(bounding_box=s, line_count=1, reverse=True)
     point_list = [p for p in shader.path()]
     assert_equal(s.bottom_right_point, point_list[0])
     assert_equal(s.top_left_point, point_list[1])
Beispiel #7
0
 def test_wshader_1_line_has_2_points_on_path(self):
     s = Square()
     shader = WShader(bounding_box=s, line_count=1)
     point_list = [p for p in shader.path()]
     assert_equal(len(point_list), 2)
Beispiel #8
0
 def test_path(self):
     s = Square()
     c = sum([1 for i in s.path()])
     assert_equals(c, 5)
Beispiel #9
0
 def test_top_line(self):
     s = Square(Point(0, 0), 2)
     expected = Line(Point(-1, 1), Point(1, 1))
     assert_equal(s.top_line, expected)
Beispiel #10
0
 def test_bottom_line(self):
     s = Square(Point(0, 0), 2)
     expected = Line(Point(-1, -1), Point(1, -1))
     assert_equal(s.bottom_line, expected)
Beispiel #11
0
 def test_point_from_string(self):
     s = Square()
     assert_equals(s.top_left_point, s.get_point("tl"))
Beispiel #12
0
 def test_path_starts_and_ends_on_sames_point(self):
     s = Square()
     point_list = [p for p in s.path()]
     assert_is(point_list[0], point_list[-1])