def test_translate_override_bounds(): # Translate a paper that has overridden bounds. The bounds update as well. paper = Paper() paper.override_bounds(0, 0, 1, 1) paper.translate((3, 4)) assert_equal( paper.bounds(), Bounds(3, 4, 4, 5) ) # When bounds=False is passed, then the bounds do not update. paper = Paper() paper.override_bounds(0, 0, 1, 1) paper.translate((3, 4), bounds=False) assert_equal(paper.bounds(), Bounds(0, 0, 1, 1)) # This also works if the bounds are not overridden. p = Pen() p.fill_mode() p.move_to((0.5, 0.5)) p.circle(0.5) assert_equal(p.paper.bounds(), Bounds(0, 0, 1, 1)) p.paper.translate((3, 4), bounds=False) assert_equal(p.paper.bounds(), Bounds(0, 0, 1, 1)) assert_equal(p.last_path().bounds(), Bounds(3, 4, 4, 5))
def test_join_paths_turn_back_no_joint(): p = Pen() p.stroke_mode(1.0) p.move_to((0, 0)) p.turn_to(0) p.line_forward(10) p.turn_right(180) p.break_stroke() p.line_forward(5) p.paper.join_paths() line1, line2 = p.last_path().segments assert line1.end_joint_illegal assert line2.start_joint_illegal assert_path_data(p, 1, ('M0.0,-0.5 L0.0,0.5 L10.0,0.5 L10.0,-0.5 ' 'L5.0,-0.5 L5.0,0.5 L10.0,0.5 L10.0,-0.5 L0.0,-0.5 z'))
def test_join_paths_turn_back_no_joint(): p = Pen() p.stroke_mode(1.0) p.move_to((0, 0)) p.turn_to(0) p.line_forward(10) p.turn_right(180) p.break_stroke() p.line_forward(5) p.paper.join_paths() line1, line2 = p.last_path().segments assert line1.end_joint_illegal assert line2.start_joint_illegal assert_path_data( p, 1, ( 'M0.0,-0.5 L0.0,0.5 L10.0,0.5 L10.0,-0.5 ' 'L5.0,-0.5 L5.0,0.5 L10.0,0.5 L10.0,-0.5 L0.0,-0.5 z' ) )
def test_translate_override_bounds(): # Translate a paper that has overridden bounds. The bounds update as well. paper = Paper() paper.override_bounds(0, 0, 1, 1) paper.translate((3, 4)) assert_equal(paper.bounds(), Bounds(3, 4, 4, 5)) # When bounds=False is passed, then the bounds do not update. paper = Paper() paper.override_bounds(0, 0, 1, 1) paper.translate((3, 4), bounds=False) assert_equal(paper.bounds(), Bounds(0, 0, 1, 1)) # This also works if the bounds are not overridden. p = Pen() p.fill_mode() p.move_to((0.5, 0.5)) p.circle(0.5) assert_equal(p.paper.bounds(), Bounds(0, 0, 1, 1)) p.paper.translate((3, 4), bounds=False) assert_equal(p.paper.bounds(), Bounds(0, 0, 1, 1)) assert_equal(p.last_path().bounds(), Bounds(3, 4, 4, 5))