コード例 #1
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def corner(self, prev_dir, curr_dir):
     # bezier circle estimate
     kappa = 4 * (math.sqrt(2) - 1) / 3
     final = pointwise('add', self.moves[prev_dir], self.moves[curr_dir])
     control1 = pointwise('mul', kappa, self.moves[prev_dir])
     control2 = pointwise('sub', final,
         pointwise('mul', 1 - kappa, self.moves[curr_dir]))
     replacements = pointwise('div', control1 + control2 + final, 2.0)
     return 'c %s,%s %s,%s %s,%s ' % tuple(replacements)
コード例 #2
0
 def corner(self, prev_dir, curr_dir):
     # bezier circle estimate
     kappa = 4 * (math.sqrt(2) - 1) / 3
     final = pointwise('add', self.moves[prev_dir], self.moves[curr_dir])
     control1 = pointwise('mul', kappa, self.moves[prev_dir])
     control2 = pointwise('sub', final,
                          pointwise('mul', 1 - kappa, self.moves[curr_dir]))
     replacements = pointwise('div', control1 + control2 + final, 2.0)
     return 'c %s,%s %s,%s %s,%s ' % tuple(replacements)
コード例 #3
0
    def can_move(self, pos, direction):
        # we always keep the blob on the right

        n1 = self.neighbours[direction]
        n2 = self.neighbours[(direction + 1) % self.n_directions]

        value1 = self.get_value(*pointwise('add', pos, n1))
        value2 = self.get_value(*pointwise('add', pos, n2))

        return (value1 == 0 and value2 == 1)
コード例 #4
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
    def can_move(self, pos, direction):
        # we always keep the blob on the right

        n1 = self.neighbours[direction]
        n2 = self.neighbours[(direction + 1) % self.n_directions]

        value1 = self.get_value(*pointwise('add', pos, n1))
        value2 = self.get_value(*pointwise('add', pos, n2))

        return (value1 == 0 and value2 == 1)
コード例 #5
0
    def start_draw(self, pos, direction):
        start = pointwise('add', pos,
                          pointwise('div', self.moves[direction], 2.0))

        return '<path d="M %s %s ' % start
コード例 #6
0
 def move(self, pos, direction):
     offset = self.moves[direction]
     return pointwise('add', pos, offset)
コード例 #7
0
 def test_empty(self):
     self.assertEqual(pointwise('add', [], []), [])
コード例 #8
0
 def test_singleton(self):
     self.assertEqual(pointwise('add', [1, 1], 1), [2, 2])
コード例 #9
0
 def test_tuple(self):
     self.assertEqual(pointwise('add', [1, 1], (2, 2)), (3, 3))
コード例 #10
0
 def test_add(self):
     self.assertEqual(pointwise('add', [1, 1], [2, 2]), [3, 3])
コード例 #11
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
    def start_draw(self, pos, direction):
        start = pointwise('add', pos,
            pointwise('div', self.moves[direction], 2.0))

        return '<path d="M %s %s ' % start
コード例 #12
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def move(self, pos, direction):
     offset = self.moves[direction]
     return pointwise('add', pos, offset)
コード例 #13
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def test_empty(self):
     self.assertEqual(pointwise('add', [], []), [])
コード例 #14
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def test_singleton(self):
     self.assertEqual(pointwise('add', [1, 1], 1), [2, 2])
コード例 #15
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def test_tuple(self):
     self.assertEqual(pointwise('add', [1, 1], (2, 2)), (3, 3))
コード例 #16
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def test_add(self):
     self.assertEqual(pointwise('add', [1, 1], [2, 2]), [3, 3])