File: test_approximate.py

package info (click to toggle)
python-svgelements 1.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 764 kB
  • sloc: python: 11,859; sh: 6; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 665 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import unittest
from random import *

from svgelements import *


def get_random_cubic_bezier():
    return CubicBezier((random() * 50, random() * 50), (random() * 50, random() * 50),
                       (random() * 50, random() * 50), (random() * 50, random() * 50))


class TestElementApproximation(unittest.TestCase):

    def test_cubic_bezier_arc_approximation(self):
        n = 50
        for _ in range(n):
            b = get_random_cubic_bezier()
            path = Move(b.start) + Path([b])
            path2 = Path(path)
            path2.approximate_bezier_with_circular_arcs(error=0.001)
            path2.approximate_arcs_with_cubics(error=0.001)