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