def draw(self, x, y, char=None, colour=7, bg=0, thin=False):
        # Define line end points.
        x0 = self._x
        y0 = self._y
        x1 = int(round(x, 1)) * 2
        y1 = int(round(y, 1)) * 2

        # Remember last point for next line.
        self._x = x1
        self._y = y1

        dx = abs(x1 - x0)
        dy = abs(y1 - y0)

        sx = -1 if x0 > x1 else 1
        sy = -1 if y0 > y1 else 1

        x_range = range(0, 2) if sx > 0 else range(1, -1, -1)
        y_range = range(0, 2) if sy > 0 else range(1, -1, -1)

        x = x0
        y = y0

        if dx > dy:
            err = dx
            while x != x1:
                next_chars = [0, 0]
                px = x & ~1
                py = y & ~1
                for ix in x_range:
                    if y >= py and y - py < 2:
                        next_chars[0] |= 2 ** ix * 4 ** (y % 2)
                    else:
                        next_chars[1] |= 2 ** ix * 4 ** (y % 2)
                    if not thin:
                        if y + sy >= py and y + sy - py < 2:
                            next_chars[0] |= 2 ** ix * 4 ** ((y + sy) % 2)
                        else:
                            next_chars[1] |= 2 ** ix * 4 ** ((y + sy) % 2)
                    err -= 2 * dy
                    if err < 0:
                        y += sy
                        err += 2 * dx
                    x += sx

                if char is None:
                    self.print_at(self._line_chars[next_chars[0]], px//2, py//2,
                                  colour, bg=bg)
                    if next_chars[1] != 0:
                        self.print_at(self._line_chars[next_chars[1]],
                                      px // 2, py // 2 + sy, colour, bg=bg)
                elif char == " ":
                    self.print_at(char, px // 2, py // 2, bg=bg)
                    self.print_at(char, px // 2, py // 2 + sy, bg=bg)
                else:
                    self.print_at(char, px // 2, py // 2, colour, bg=bg)
        else:
            err = dy
            while y != y1:
                next_chars = [0, 0]
                px = x & ~1
                py = y & ~1
                for iy in y_range:
                    if x >= px and x - px < 2:
                        next_chars[0] |= 2 ** (x % 2) * 4 ** iy
                    else:
                        next_chars[1] |= 2 ** (x % 2) * 4 ** iy
                    if not thin:
                        if x + sx >= px and x + sx - px < 2:
                            next_chars[0] |= 2 ** ((x + sx) % 2) * 4 ** iy
                        else:
                            next_chars[1] |= 2 ** ((x + sx) % 2) * 4 ** iy
                    err -= 2 * dx
                    if err < 0:
                        x += sx
                        err += 2 * dy
                    y += sy

                if char is None:
                    self.print_at(self._line_chars[next_chars[0]], px//2, py//2,
                                  colour, bg=bg)
                    if next_chars[1] != 0:
                        self.print_at(
                            self._line_chars[next_chars[1]], px//2 + sx, py//2,
                            colour, bg=bg)
                elif char == " ":
                    self.print_at(char, px // 2, py // 2, bg=bg)
                    self.print_at(char, px // 2 + sx, py // 2, bg=bg)
                else:
                    self.print_at(char, px // 2, py // 2, colour, bg=bg)
Prepare the query for computing a result that contains aggregate annotations.
dataset/ETHPy150Open peterbrittain/asciimatics/asciimatics/screen.py/_AbstractCanvas.draw--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.5/django/db/models/query.py/QuerySet._setup_aggregate_query