(
            self, cx, cy, rx, ry, attr,
            qua0=-1, x0=-1, y0=-1, line0=False,
            qua1=-1, x1=-1, y1=-1, line1=False
        )
Draw ellipse using the midpoint algorithm.
Draw ellipse using the midpoint algorithm.
Draw ellipse using the midpoint algorithm .
def _draw_ellipse(
            self, cx, cy, rx, ry, attr,
            qua0=-1, x0=-1, y0=-1, line0=False,
            qua1=-1, x1=-1, y1=-1, line1=False
        ):
        """Draw ellipse using the midpoint algorithm."""
        # for algorithm see http://members.chello.at/~easyfilter/bresenham.html
        # find invisible quadrants
        if qua0 == -1:
            hide_qua = []
        elif qua0 < qua1 or qua0 == qua1 and _quadrant_gte(qua0, x1, y1, x0, y0):
            hide_qua = list(range(0, qua0)) + list(range(qua1+1, 4))
        else:
            hide_qua = list(range(qua1+1, qua0))
        # error increment
        dx = 16 * (1-2*rx) * ry * ry
        dy = 16 * rx * rx
        ddy = 32 * rx * rx
        ddx = 32 * ry * ry
        # error for first step
        err = dx + dy
        x, y = rx, 0
        while True:
            for quadrant in range(0,4):
                # skip invisible arc sectors
                if quadrant in hide_qua:
                    continue
                elif qua0 != qua1 and quadrant == qua0 and _quadrant_gt(qua0, x0, y0, x, y):
                    continue
                elif qua0 != qua1 and quadrant == qua1 and _quadrant_gt(qua1, x, y, x1, y1):
                    continue
                elif qua0 == qua1 and quadrant == qua0:
                    if _quadrant_gte(qua0, x1, y1, x0, y0):
                        if _quadrant_gt(qua0, x, y, x1, y1) or _quadrant_gt(qua0, x0, y0, x, y):
                            continue
                    else:
                        if _quadrant_gt(qua0, x, y, x1, y1) and _quadrant_gt(qua0, x0, y0, x, y):
                            continue
                quad_x, quad_y = _quadrant_coord(quadrant, cx, cy, x, y)
                self.graph_view[quad_y, quad_x] = attr
            # bresenham error step
            e2 = 2 * err
            if (e2 <= dy):
                y += 1
                dy += ddy
                err += dy
            if (e2 >= dx or e2 > dy):
                x -= 1
                dx += ddx
                err += dx
            # NOTE - err changes sign at the change from y increase to x increase
            if (x < 0):
                break
        # too early stop of flat vertical ellipses
        # finish tip of ellipse
        while (y < ry):
            self.graph_view[cy+y, cx] = attr
            self.graph_view[cy-y, cx] = attr
            y += 1
        # draw pie-slice lines
        if line0:
            self._draw_line(cx, cy, *_quadrant_coord(qua0, cx, cy, x0, y0), attr=attr)
        if line1:
            self._draw_line(cx, cy, *_quadrant_coord(qua1, cx, cy, x1, y1), attr=attr)
def _draw_ellipse ( self , cx , cy , rx , ry , attr , qua0 = - 1 , x0 = - 1 , y0 = - 1 , line0 = False , qua1 = - 1 , x1 = - 1 , y1 = - 1 , line1 = False ) : # for algorithm see http://members.chello.at/~easyfilter/bresenham.html # find invisible quadrants if qua0 == - 1 : hide_qua = [ ] elif qua0 < qua1 or qua0 == qua1 and _quadrant_gte ( qua0 , x1 , y1 , x0 , y0 ) : hide_qua = list ( range ( 0 , qua0 ) ) + list ( range ( qua1 + 1 , 4 ) ) else : hide_qua = list ( range ( qua1 + 1 , qua0 ) ) # error increment dx = 16 * ( 1 - 2 * rx ) * ry * ry dy = 16 * rx * rx ddy = 32 * rx * rx ddx = 32 * ry * ry # error for first step err = dx + dy x , y = rx , 0 while True : for quadrant in range ( 0 , 4 ) : # skip invisible arc sectors if quadrant in hide_qua : continue elif qua0 != qua1 and quadrant == qua0 and _quadrant_gt ( qua0 , x0 , y0 , x , y ) : continue elif qua0 != qua1 and quadrant == qua1 and _quadrant_gt ( qua1 , x , y , x1 , y1 ) : continue elif qua0 == qua1 and quadrant == qua0 : if _quadrant_gte ( qua0 , x1 , y1 , x0 , y0 ) : if _quadrant_gt ( qua0 , x , y , x1 , y1 ) or _quadrant_gt ( qua0 , x0 , y0 , x , y ) : continue else : if _quadrant_gt ( qua0 , x , y , x1 , y1 ) and _quadrant_gt ( qua0 , x0 , y0 , x , y ) : continue quad_x , quad_y = _quadrant_coord ( quadrant , cx , cy , x , y ) self . graph_view [ quad_y , quad_x ] = attr # bresenham error step e2 = 2 * err if ( e2 <= dy ) : y += 1 dy += ddy err += dy if ( e2 >= dx or e2 > dy ) : x -= 1 dx += ddx err += dx # NOTE - err changes sign at the change from y increase to x increase if ( x < 0 ) : break # too early stop of flat vertical ellipses # finish tip of ellipse while ( y < ry ) : self . graph_view [ cy + y , cx ] = attr self . graph_view [ cy - y , cx ] = attr y += 1 # draw pie-slice lines if line0 : self . _draw_line ( cx , cy , * _quadrant_coord ( qua0 , cx , cy , x0 , y0 ) , attr = attr ) if line1 : self . _draw_line ( cx , cy , * _quadrant_coord ( qua1 , cx , cy , x1 , y1 ) , attr = attr )