def test_square(self): # Slides, positioned in a square positions = [ {'data-x': '0', 'data-y': '0'}, {'data-x': '1200', 'data-y': '0'}, None, None, {'data-x': '3600', 'data-y': '-1000'}, None, None, {'data-x': '2400', 'data-y': '-3000'}, None, None, {'data-x': '0', 'data-y': '-2000'}, None, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-x': '0', 'data-y': '0'}, {'data-x': '1200', 'data-y': '0'}, {'data-x': '2400', 'data-y': '0'}, {'data-x': '3600', 'data-y': '0'}, {'data-x': '3600', 'data-y': '-1000'}, {'data-x': '3600', 'data-y': '-2000'}, {'data-x': '3600', 'data-y': '-3000'}, {'data-x': '2400', 'data-y': '-3000'}, {'data-x': '1200', 'data-y': '-3000'}, {'data-x': '0', 'data-y': '-3000'}, {'data-x': '0', 'data-y': '-2000'}, {'data-x': '0', 'data-y': '-1000'}, ])
def test_complex_path(self): positions = [ None, None, ('m 100 100 l 200 0 l 0 200', {'data-x': 'r0', 'data-y': 'r0'}), None, None, {'data-x': '0', 'data-y': '0'}, None, ('m 100 100 l 200 0 l 0 200', {'data-x': 'r0', 'data-y': 'r0'}), None, None, {'data-x': '3000', 'data-y': '1000'}, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-x': '0', 'data-y': '0'}, {'data-x': '1600', 'data-y': '0'}, {'data-rotate': 0, 'data-x': '3200', 'data-y': '0'}, {'data-rotate': 44.99999999999999, 'data-x': '5600', 'data-y': '0'}, {'data-rotate': 90.0, 'data-x': '5600', 'data-y': '2400'}, {'data-x': '0', 'data-y': '0'}, {'data-x': '-5600', 'data-y': '-2400'}, {'data-rotate': 0, 'data-x': '-11200', 'data-y': '-4800'}, {'data-rotate': 44.99999999999999, 'data-x': '-8800', 'data-y': '-4800'}, {'data-rotate': 90.0, 'data-x': '-8800', 'data-y': '-2400'}, {'data-x': '3000', 'data-y': '1000'} ])
def test_absolute_path(self): # Position slides along a path positions = [ {'data-x': 'r0', 'data-y': 'r0', 'path': 'M 100 100 L 300 100 L 300 300', 'is_path': True}, {'is_path': True}, {'is_path': True}, {'is_path': True}, {'is_path': True}, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 2000, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 4000, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 44.99999999999999, 'data-scale': 1}, {'data-x': 4000, 'data-y': 2000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 90.0, 'data-scale': 1}, {'data-x': 4000, 'data-y': 4000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 90.0, 'data-scale': 1}, ])
def test_complex_path(self): positions = [ {'data-x': 'r0', 'data-y': 'r0'}, {'data-x': 'r1600', 'data-y': 'r0'}, {'data-x': 'r1600', 'data-y': 'r0', 'path': 'm 100 100 l 200 0 l 0 200', 'is_path': True}, {'is_path': True}, {'is_path': True}, # Note that we don't change the rotation, so it stays at 90, here. {'data-x': '0', 'data-y': '0'}, # No new x and y, previous was absolute: Stay still! {}, {'data-x': 'r0', 'data-y': 'r0', 'path': 'm 100 100 l 200 0 l 0 200', 'is_path': True}, {'is_path': True}, {'is_path': True}, {'data-x': '3000', 'data-y': '1000', 'data-rotate-z': '0'}, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 1600, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 3200, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 5600, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 44.99999999999999, 'data-scale': 1}, {'data-x': 5600, 'data-y': 2400, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 90.0, 'data-scale': 1}, # Note that we don't change the rotation, so it stays at 90, here. {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 90.0, 'data-scale': 1}, # No settings, still same place and rotation. {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 90.0, 'data-scale': 1}, # We start a path, but x and y are r0, so no movement. # However, the rotation will come from the path, so it resets to 0. {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 2400, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 44.99999999999999, 'data-scale': 1}, {'data-x': 2400, 'data-y': 2400, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 90.0, 'data-scale': 1}, {'data-x': 3000, 'data-y': 1000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, ])
def test_square(self): # Slides, positioned in a square positions = [ {'data-x': '0', 'data-y': '0'}, {'data-x': 'r1200', 'data-y': '0'}, {'data-x': 'r1200', 'data-y': '0'}, {'data-x': 'r1200', 'data-y': '0'}, {'data-x': 'r0', 'data-y': 'r-1000'}, {'data-x': 'r0', 'data-y': 'r-1000'}, {'data-x': 'r0', 'data-y': 'r-1000'}, {'data-x': 'r-1200', 'data-y': 'r0'}, {'data-x': 'r-1200', 'data-y': 'r0'}, {'data-x': 'r-1200', 'data-y': 'r0'}, {'data-x': 'r0', 'data-y': 'r1000'}, {'data-x': 'r0', 'data-y': 'r1000'}, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 1200, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 2400, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 3600, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 3600, 'data-y': -1000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 3600, 'data-y': -2000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 3600, 'data-y': -3000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 2400, 'data-y': -3000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 1200, 'data-y': -3000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 0, 'data-y': -3000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 0, 'data-y': -2000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 0, 'data-y': -1000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, ])
def test_no_position(self): # Ten slides, none have any position information: positions = [None] * 10 positions = list(calculate_positions(positions)) self.assertEqual(positions, [ { 'data-x': '0', 'data-y': '0' }, { 'data-x': '1600', 'data-y': '0' }, { 'data-x': '3200', 'data-y': '0' }, { 'data-x': '4800', 'data-y': '0' }, { 'data-x': '6400', 'data-y': '0' }, { 'data-x': '8000', 'data-y': '0' }, { 'data-x': '9600', 'data-y': '0' }, { 'data-x': '11200', 'data-y': '0' }, { 'data-x': '12800', 'data-y': '0' }, { 'data-x': '14400', 'data-y': '0' }, ])
def test_no_position(self): # Ten slides, none have any position information: positions = [None] * 10 positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-x': '0', 'data-y': '0'}, {'data-x': '1600', 'data-y': '0'}, {'data-x': '3200', 'data-y': '0'}, {'data-x': '4800', 'data-y': '0'}, {'data-x': '6400', 'data-y': '0'}, {'data-x': '8000', 'data-y': '0'}, {'data-x': '9600', 'data-y': '0'}, {'data-x': '11200', 'data-y': '0'}, {'data-x': '12800', 'data-y': '0'}, {'data-x': '14400', 'data-y': '0'}, ])
def test_relative_path(self): positions = [ None, None, ('m 100 100 l 200 0 l 0 200', { 'data-x': 'r0', 'data-y': 'r0' }), None, None, None, None, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [{ 'data-x': '0', 'data-y': '0' }, { 'data-x': '1600', 'data-y': '0' }, { 'data-rotate': 0, 'data-x': '3200', 'data-y': '0' }, { 'data-rotate': 0, 'data-x': '5200', 'data-y': '0' }, { 'data-rotate': 44.99999999999999, 'data-x': '7200', 'data-y': '0' }, { 'data-rotate': 90.0, 'data-x': '7200', 'data-y': '2000' }, { 'data-rotate': 90.0, 'data-x': '7200', 'data-y': '4000' }])
def test_relative_positioning(self): # Relative positioning is probably the most useful positioning. # It allows you to insert or remove a slide, and everything adjusts. positions = [ # First some automatic positions. None, None, # Then suddenly we move vertically! {'data-x': 'r0', 'data-y': 'r1000'}, # Continue the same way one slide. None, # Stand still {'data-x': 'r0', 'data-y': 'r0'}, # Stand still again! None, # Move a little bit {'data-x': 'r-40', 'data-y': 'r-200'}, # Go back to normal movement to the right {'data-x': 'r1600', 'data-y': 'r0'}, None, None, # Absolute movement back to start! {'data-x': '0', 'data-y': '0'}, # Absolute movement to a center for end (with zoomout for example) {'data-x': '3000', 'data-y': '1000'}, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-x': '0', 'data-y': '0'}, {'data-x': '1600', 'data-y': '0'}, {'data-x': '1600', 'data-y': '1000'}, {'data-x': '1600', 'data-y': '2000'}, {'data-x': '1600', 'data-y': '2000'}, {'data-x': '1600', 'data-y': '2000'}, {'data-x': '1560', 'data-y': '1800'}, {'data-x': '3160', 'data-y': '1800'}, {'data-x': '4760', 'data-y': '1800'}, {'data-x': '6360', 'data-y': '1800'}, {'data-x': '0', 'data-y': '0'}, {'data-x': '3000', 'data-y': '1000'}, ])
def test_absolute_path(self): # Position slides along a path positions = [ ('M 100 100 L 300 100 L 300 300', {'data-x': 'r0', 'data-y': 'r0'}), None, None, None, None, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-rotate': 0, 'data-x': '0', 'data-y': '0'}, {'data-rotate': 0, 'data-x': '2000', 'data-y': '0'}, {'data-rotate': 44.99999999999999, 'data-x': '4000', 'data-y': '0'}, {'data-rotate': 90.0, 'data-x': '4000', 'data-y': '2000'}, {'data-rotate': 90.0, 'data-x': '4000', 'data-y': '4000'}, ])
def test_absolute_path(self): # Position slides along a path positions = [ ('M 100 100 L 300 100 L 300 300', { 'data-x': 'r0', 'data-y': 'r0' }), None, None, None, None, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ { 'data-rotate': 0, 'data-x': '0', 'data-y': '0' }, { 'data-rotate': 0, 'data-x': '2000', 'data-y': '0' }, { 'data-rotate': 44.99999999999999, 'data-x': '4000', 'data-y': '0' }, { 'data-rotate': 90.0, 'data-x': '4000', 'data-y': '2000' }, { 'data-rotate': 90.0, 'data-x': '4000', 'data-y': '4000' }, ])
def test_relative_path(self): positions = [ {'data-x': 'r0', 'data-y': 'r0'}, {'data-x': 'r1600', 'data-y': 'r0'}, {'data-x': 'r1600', 'data-y': 'r0', 'is_path': True, 'path': 'm 100 100 l 200 0 l 0 200', }, {'data-x': 'r0', 'data-y': 'r0', 'is_path': True}, {'data-x': 'r0', 'data-y': 'r0', 'is_path': True}, {'data-x': 'r1600', 'data-y': 'r0'}, {'data-x': 'r0', 'data-y': 'r2400'}, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 1600, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 3200, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, # This point is exactly on a 90 degree angle. Therefore, # it's angle is calculated as 45 degrees, it being the # average. {'data-x': 5600, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 44.99999999999999, 'data-scale': 1}, {'data-x': 5600, 'data-y': 2400, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 90.0, 'data-scale': 1}, {'data-x': 7200, 'data-y': 2400, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 90.0, 'data-scale': 1}, {'data-x': 7200, 'data-y': 4800, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 90.0, 'data-scale': 1}, ])
def test_relative_path(self): positions = [ None, None, ('m 100 100 l 200 0 l 0 200', {'data-x': 'r0', 'data-y': 'r0'}), None, None, None, None, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-x': '0', 'data-y': '0'}, {'data-x': '1600', 'data-y': '0'}, {'data-rotate': 0, 'data-x': '3200', 'data-y': '0'}, {'data-rotate': 0, 'data-x': '5200', 'data-y': '0'}, {'data-rotate': 44.99999999999999, 'data-x': '7200', 'data-y': '0'}, {'data-rotate': 90.0, 'data-x': '7200', 'data-y': '2000'}, {'data-rotate': 90.0, 'data-x': '7200', 'data-y': '4000'} ])
def test_square(self): # Slides, positioned in a square positions = [ {"data-x": "0", "data-y": "0"}, {"data-x": "r1200", "data-y": "0"}, {"data-x": "r1200", "data-y": "0"}, {"data-x": "r1200", "data-y": "0"}, {"data-x": "r0", "data-y": "r-1000"}, {"data-x": "r0", "data-y": "r-1000"}, {"data-x": "r0", "data-y": "r-1000"}, {"data-x": "r-1200", "data-y": "r0"}, {"data-x": "r-1200", "data-y": "r0"}, {"data-x": "r-1200", "data-y": "r0"}, {"data-x": "r0", "data-y": "r1000"}, {"data-x": "r0", "data-y": "r1000"}, ] positions = list(calculate_positions(positions)) self.assertEqual( positions, [ { "data-x": 0, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 1200, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 2400, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 3600, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 3600, "data-y": -1000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 3600, "data-y": -2000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 3600, "data-y": -3000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 2400, "data-y": -3000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 1200, "data-y": -3000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 0, "data-y": -3000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 0, "data-y": -2000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 0, "data-y": -1000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, ], )
def test_complex_path(self): positions = [ None, None, ('m 100 100 l 200 0 l 0 200', { 'data-x': 'r0', 'data-y': 'r0' }), None, None, { 'data-x': '0', 'data-y': '0' }, None, ('m 100 100 l 200 0 l 0 200', { 'data-x': 'r0', 'data-y': 'r0' }), None, None, { 'data-x': '3000', 'data-y': '1000' }, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [{ 'data-x': '0', 'data-y': '0' }, { 'data-x': '1600', 'data-y': '0' }, { 'data-rotate': 0, 'data-x': '3200', 'data-y': '0' }, { 'data-rotate': 44.99999999999999, 'data-x': '5600', 'data-y': '0' }, { 'data-rotate': 90.0, 'data-x': '5600', 'data-y': '2400' }, { 'data-x': '0', 'data-y': '0' }, { 'data-x': '-5600', 'data-y': '-2400' }, { 'data-rotate': 0, 'data-x': '-11200', 'data-y': '-4800' }, { 'data-rotate': 44.99999999999999, 'data-x': '-8800', 'data-y': '-4800' }, { 'data-rotate': 90.0, 'data-x': '-8800', 'data-y': '-2400' }, { 'data-x': '3000', 'data-y': '1000' }])
def test_relative_positioning(self): # Relative positioning is probably the most useful positioning. # It allows you to insert or remove a slide, and everything adjusts. positions = [ # First some automatic positions. None, None, # Then suddenly we move vertically! { 'data-x': 'r0', 'data-y': 'r1000' }, # Continue the same way one slide. None, # Stand still { 'data-x': 'r0', 'data-y': 'r0' }, # Stand still again! None, # Move a little bit { 'data-x': 'r-40', 'data-y': 'r-200' }, # Go back to normal movement to the right { 'data-x': 'r1600', 'data-y': 'r0' }, None, None, # Absolute movement back to start! { 'data-x': '0', 'data-y': '0' }, # Absolute movement to a center for end (with zoomout for example) { 'data-x': '3000', 'data-y': '1000' }, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ { 'data-x': '0', 'data-y': '0' }, { 'data-x': '1600', 'data-y': '0' }, { 'data-x': '1600', 'data-y': '1000' }, { 'data-x': '1600', 'data-y': '2000' }, { 'data-x': '1600', 'data-y': '2000' }, { 'data-x': '1600', 'data-y': '2000' }, { 'data-x': '1560', 'data-y': '1800' }, { 'data-x': '3160', 'data-y': '1800' }, { 'data-x': '4760', 'data-y': '1800' }, { 'data-x': '6360', 'data-y': '1800' }, { 'data-x': '0', 'data-y': '0' }, { 'data-x': '3000', 'data-y': '1000' }, ])
def test_square(self): # Slides, positioned in a square positions = [ { 'data-x': '0', 'data-y': '0' }, { 'data-x': '1200', 'data-y': '0' }, None, None, { 'data-x': '3600', 'data-y': '-1000' }, None, None, { 'data-x': '2400', 'data-y': '-3000' }, None, None, { 'data-x': '0', 'data-y': '-2000' }, None, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ { 'data-x': '0', 'data-y': '0' }, { 'data-x': '1200', 'data-y': '0' }, { 'data-x': '2400', 'data-y': '0' }, { 'data-x': '3600', 'data-y': '0' }, { 'data-x': '3600', 'data-y': '-1000' }, { 'data-x': '3600', 'data-y': '-2000' }, { 'data-x': '3600', 'data-y': '-3000' }, { 'data-x': '2400', 'data-y': '-3000' }, { 'data-x': '1200', 'data-y': '-3000' }, { 'data-x': '0', 'data-y': '-3000' }, { 'data-x': '0', 'data-y': '-2000' }, { 'data-x': '0', 'data-y': '-1000' }, ])
def test_relative_positioning(self): # Relative positioning is probably the most useful positioning. # It allows you to insert or remove a slide, and everything adjusts. positions = [ # The first two slides are just default positons { 'data-x': 'r0', 'data-y': 'r0' }, { 'data-x': 'r1600', 'data-y': 'r0' }, # Then suddenly we move vertically! { 'data-x': 'r0', 'data-y': 'r1000' }, # Continue the same way one slide. { 'data-x': 'r0', 'data-y': 'r1000' }, # Stand still { 'data-x': 'r0', 'data-y': 'r0' }, # Stand still again! { 'data-x': 'r0', 'data-y': 'r0' }, # Move a little bit { 'data-x': 'r-40', 'data-y': 'r-200' }, # Go back to normal movement to the right { 'data-x': 'r1600', 'data-y': 'r0' }, { 'data-x': 'r1600', 'data-y': 'r0' }, { 'data-x': 'r1600', 'data-y': 'r0' }, # Absolute movement back to start! { 'data-x': '0', 'data-y': '0' }, # Absolute movement to a center for end (with zoomout for example) { 'data-x': '3000', 'data-y': '1000' }, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ { 'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 1600, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 1600, 'data-y': 1000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 1600, 'data-y': 2000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 1600, 'data-y': 2000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 1600, 'data-y': 2000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 1560, 'data-y': 1800, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 3160, 'data-y': 1800, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 4760, 'data-y': 1800, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 6360, 'data-y': 1800, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, { 'data-x': 3000, 'data-y': 1000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1 }, ])
def test_relative_path(self): positions = [ {"data-x": "r0", "data-y": "r0"}, {"data-x": "r1600", "data-y": "r0"}, { "data-x": "r1600", "data-y": "r0", "is_path": True, "path": "m 100 100 l 200 0 l 0 200", }, {"data-x": "r0", "data-y": "r0", "is_path": True}, {"data-x": "r0", "data-y": "r0", "is_path": True}, {"data-x": "r1600", "data-y": "r0"}, {"data-x": "r0", "data-y": "r2400"}, ] positions = list(calculate_positions(positions)) self.assertEqual( positions, [ { "data-x": 0, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 1600, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 3200, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, # This point is exactly on a 90 degree angle. Therefore, # it's angle is calculated as 45 degrees, it being the # average. { "data-x": 5600, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 44.99999999999999, "data-scale": 1, }, { "data-x": 5600, "data-y": 2400, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 90.0, "data-scale": 1, }, { "data-x": 7200, "data-y": 2400, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 90.0, "data-scale": 1, }, { "data-x": 7200, "data-y": 4800, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 90.0, "data-scale": 1, }, ], )
def test_complex_path(self): positions = [ {"data-x": "r0", "data-y": "r0"}, {"data-x": "r1600", "data-y": "r0"}, { "data-x": "r1600", "data-y": "r0", "path": "m 100 100 l 200 0 l 0 200", "is_path": True, }, {"is_path": True}, {"is_path": True}, # Note that we don't change the rotation, so it stays at 90, here. {"data-x": "0", "data-y": "0"}, # No new x and y, previous was absolute: Stay still! {}, { "data-x": "r0", "data-y": "r0", "path": "m 100 100 l 200 0 l 0 200", "is_path": True, }, {"is_path": True}, {"is_path": True}, {"data-x": "3000", "data-y": "1000", "data-rotate-z": "0"}, ] positions = list(calculate_positions(positions)) self.assertEqual( positions, [ { "data-x": 0, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 1600, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 3200, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 5600, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 44.99999999999999, "data-scale": 1, }, { "data-x": 5600, "data-y": 2400, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 90.0, "data-scale": 1, }, # Note that we don't change the rotation, so it stays at 90, here. { "data-x": 0, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 90.0, "data-scale": 1, }, # No settings, still same place and rotation. { "data-x": 0, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 90.0, "data-scale": 1, }, # We start a path, but x and y are r0, so no movement. # However, the rotation will come from the path, so it resets to 0. { "data-x": 0, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 2400, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 44.99999999999999, "data-scale": 1, }, { "data-x": 2400, "data-y": 2400, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 90.0, "data-scale": 1, }, { "data-x": 3000, "data-y": 1000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, ], )
def test_absolute_path(self): # Position slides along a path positions = [ { "data-x": "r0", "data-y": "r0", "path": "M 100 100 L 300 100 L 300 300", "is_path": True, }, {"is_path": True}, {"is_path": True}, {"is_path": True}, {"is_path": True}, ] positions = list(calculate_positions(positions)) self.assertEqual( positions, [ { "data-x": 0, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 2000, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 0, "data-scale": 1, }, { "data-x": 4000, "data-y": 0, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 44.99999999999999, "data-scale": 1, }, { "data-x": 4000, "data-y": 2000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 90.0, "data-scale": 1, }, { "data-x": 4000, "data-y": 4000, "data-z": 0, "data-rotate-x": 0, "data-rotate-y": 0, "data-rotate-z": 90.0, "data-scale": 1, }, ], )
def test_relative_positioning(self): # Relative positioning is probably the most useful positioning. # It allows you to insert or remove a slide, and everything adjusts. positions = [ # The first two slides are just default positons {'data-x': 'r0', 'data-y': 'r0'}, {'data-x': 'r1600', 'data-y': 'r0'}, # Then suddenly we move vertically! {'data-x': 'r0', 'data-y': 'r1000'}, # Continue the same way one slide. {'data-x': 'r0', 'data-y': 'r1000'}, # Stand still {'data-x': 'r0', 'data-y': 'r0'}, # Stand still again! {'data-x': 'r0', 'data-y': 'r0'}, # Move a little bit {'data-x': 'r-40', 'data-y': 'r-200'}, # Go back to normal movement to the right {'data-x': 'r1600', 'data-y': 'r0'}, {'data-x': 'r1600', 'data-y': 'r0'}, {'data-x': 'r1600', 'data-y': 'r0'}, # Absolute movement back to start! {'data-x': '0', 'data-y': '0'}, # Absolute movement to a center for end (with zoomout for example) {'data-x': '3000', 'data-y': '1000'}, ] positions = list(calculate_positions(positions)) self.assertEqual(positions, [ {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 1600, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 1600, 'data-y': 1000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 1600, 'data-y': 2000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 1600, 'data-y': 2000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 1600, 'data-y': 2000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 1560, 'data-y': 1800, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 3160, 'data-y': 1800, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 4760, 'data-y': 1800, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 6360, 'data-y': 1800, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, {'data-x': 3000, 'data-y': 1000, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0, 'data-scale': 1}, ])