Exemple #1
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)
Exemple #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)
Exemple #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)
Exemple #4
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)
Exemple #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
Exemple #6
0
 def move(self, pos, direction):
     offset = self.moves[direction]
     return pointwise('add', pos, offset)
Exemple #7
0
 def test_empty(self):
     self.assertEqual(pointwise('add', [], []), [])
Exemple #8
0
 def test_singleton(self):
     self.assertEqual(pointwise('add', [1, 1], 1), [2, 2])
Exemple #9
0
 def test_tuple(self):
     self.assertEqual(pointwise('add', [1, 1], (2, 2)), (3, 3))
Exemple #10
0
 def test_add(self):
     self.assertEqual(pointwise('add', [1, 1], [2, 2]), [3, 3])
Exemple #11
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
Exemple #12
0
 def move(self, pos, direction):
     offset = self.moves[direction]
     return pointwise('add', pos, offset)
Exemple #13
0
 def test_empty(self):
     self.assertEqual(pointwise('add', [], []), [])
Exemple #14
0
 def test_singleton(self):
     self.assertEqual(pointwise('add', [1, 1], 1), [2, 2])
Exemple #15
0
 def test_tuple(self):
     self.assertEqual(pointwise('add', [1, 1], (2, 2)), (3, 3))
Exemple #16
0
 def test_add(self):
     self.assertEqual(pointwise('add', [1, 1], [2, 2]), [3, 3])