コード例 #1
0
    def test_generate_quadratic_smooth_curve_relative(self):
        # Given
        command = (1.0, -2.0)
        self.generator._UIBezierPathGenerator__current_pos = Point(1.0, 4.0)
        self.generator._UIBezierPathGenerator__last_quadratic_control_point = Point(
            2.0, -4.0)

        # When
        result = self.generator._UIBezierPathGenerator__generate_quadratic_smooth_curve(
            command, coords=CoordinateSystem.RELATIVE)

        # Then
        assert result == 'path.addQuadCurve(to: CGPoint(x: 2.0, y: 2.0), ' \
                         'controlPoint: CGPoint(x: 0.0, y: 12.0))'
コード例 #2
0
    def test_generate_cubic_smooth_curve_relative(self):
        # Given
        command = (1.0, -2.0, -3.0, 4.0)
        self.generator._UIBezierPathGenerator__current_pos = Point(26.0, -32.0)
        self.generator._UIBezierPathGenerator__last_cubic_control_point = Point(
            -2.0, -32.0)

        # When
        result = self.generator._UIBezierPathGenerator__generate_cubic_smooth_curve(
            command, coords=CoordinateSystem.RELATIVE)

        # Then
        assert result == 'path.addCurve(to: CGPoint(x: 23.0, y: -28.0), ' \
                         'controlPoint1: CGPoint(x: 54.0, y: -32.0), ' \
                         'controlPoint2: CGPoint(x: 27.0, y: -34.0))'
コード例 #3
0
    def test_generate_elliptical_curve_absolute_previous_relative(self):
        # Given
        # rx, ry, angle, large_arc_flag, sweep-flag, x, y
        command = (6.0, 6.0, 10.0, 1.0, 0.0, 14.0, 10.0)
        self.generator._UIBezierPathGenerator__current_pos = Point(1.0, 4.0)

        # When
        result = self.generator._UIBezierPathGenerator__generate_elliptical_curve(
            command, coords=CoordinateSystem.RELATIVE)

        # Then
        assert result == 'path.addArc(withCenter: CGPoint(x: 8.0, y: 9.0), ' \
                         'radius: CGFloat(6.0), startAngle: CGFloat(0.0), ' \
                         'endAngle: CGFloat(360.0), clockwise: false)'
        assert self.generator._UIBezierPathGenerator__current_pos == Point(
            15.0, 14.0)
コード例 #4
0
    def test_generate_line_to_h_relative(self):
        # Given
        command = (1.0, )
        self.generator._UIBezierPathGenerator__current_pos = Point(-1.0, 3.0)

        # When
        result = self.generator._UIBezierPathGenerator__generate_horizontal_line_to(
            command, coords=CoordinateSystem.RELATIVE)

        # Then
        assert result == 'path.addLine(to: CGPoint(x: 0.0, y: 3.0))'
コード例 #5
0
    def test_generate_line_to_absolute(self):
        # Given
        command = (1.0, 2.0)
        self.generator._UIBezierPathGenerator__current_pos = Point(2, 1)

        # When
        result = self.generator._UIBezierPathGenerator__generate_line_to(
            command, coords=CoordinateSystem.ABSOLUTE)

        # Then
        assert result == 'path.addLine(to: CGPoint(x: 1.0, y: 2.0))'
コード例 #6
0
    def test_generate_move_to_relative(self):
        # Given
        command = (1.0, 2.0)
        self.generator._UIBezierPathGenerator__current_pos = Point(1, -2)

        # When
        result = self.generator._UIBezierPathGenerator__generate_move_to(
            command, coords=CoordinateSystem.RELATIVE)

        # Then
        assert result == 'path.move(to: CGPoint(x: 2.0, y: 0.0))'
コード例 #7
0
    def test_generate_cubic_curve_relative(self):
        # Given
        command = (1.0, 2.0, 3.0, 4.0, 5.0, 6.0)
        self.generator._UIBezierPathGenerator__current_pos = Point(-1.0, 2.0)

        # When
        result = self.generator._UIBezierPathGenerator__generate_cubic_curve(
            command, coords=CoordinateSystem.RELATIVE)

        # Then
        assert result == 'path.addCurve(to: CGPoint(x: 4.0, y: 8.0), ' \
                         'controlPoint1: CGPoint(x: 0.0, y: 4.0), ' \
                         'controlPoint2: CGPoint(x: 2.0, y: 6.0))'