(
            self, x0, y0, r, attr,
            oct0=-1, coo0=-1, line0=False,
            oct1=-1, coo1=-1, line1=False
        )
Draw a circle sector using the midpoint algorithm.
Draw a circle sector using the midpoint algorithm.
Draw a circle sector using the midpoint algorithm .
def _draw_circle(
            self, x0, y0, r, attr,
            oct0=-1, coo0=-1, line0=False,
            oct1=-1, coo1=-1, line1=False
        ):
        """Draw a circle sector using the midpoint algorithm."""
        # see e.g. http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
        # find invisible octants
        if oct0 == -1:
            hide_oct = []
        elif oct0 < oct1 or oct0 == oct1 and _octant_gte(oct0, coo1, coo0):
            hide_oct = list(range(0, oct0)) + list(range(oct1+1, 8))
        else:
            hide_oct = list(range(oct1+1, oct0))
        # if oct1==oct0:
        # ----|.....|--- : coo1 lt coo0 : print if y in [0,coo1] or in [coo0, r]
        # ....|-----|... ; coo1 gte coo0: print if y in [coo0,coo1]
        x, y = r, 0
        bres_error = 1-r
        while x >= y:
            for octant in range(0, 8):
                if octant in hide_oct:
                    continue
                elif oct0 != oct1 and octant == oct0 and _octant_gt(oct0, coo0, y):
                    continue
                elif oct0 != oct1 and octant == oct1 and _octant_gt(oct1, y, coo1):
                    continue
                elif oct0 == oct1 and octant == oct0:
                    # if coo1 >= coo0
                    if _octant_gte(oct0, coo1, coo0):
                        # if y > coo1 or y < coo0
                        # (don't draw if y is outside coo's)
                        if _octant_gt(oct0, y, coo1) or _octant_gt(oct0, coo0,y):
                            continue
                    else:
                        # if coo0 > y > c001
                        # (don't draw if y is between coo's)
                        if _octant_gt(oct0, y, coo1) and _octant_gt(oct0, coo0, y):
                            continue
                oct_x, oct_y = _octant_coord(octant, x0, y0, x, y)
                self.graph_view[oct_y, oct_x] = attr
            # remember endpoints for pie sectors
            if y == coo0:
                coo0x = x
            if y == coo1:
                coo1x = x
            # bresenham error step
            y += 1
            if bres_error < 0:
                bres_error += 2*y+1
            else:
                x -= 1
                bres_error += 2*(y-x+1)
        # draw pie-slice lines
        if line0:
            self._draw_line(x0, y0, *_octant_coord(oct0, x0, y0, coo0x, coo0), attr=attr)
        if line1:
            self._draw_line(x0, y0, *_octant_coord(oct1, x0, y0, coo1x, coo1), attr=attr)
def _draw_circle ( self , x0 , y0 , r , attr , oct0 = - 1 , coo0 = - 1 , line0 = False , oct1 = - 1 , coo1 = - 1 , line1 = False ) : # see e.g. http://en.wikipedia.org/wiki/Midpoint_circle_algorithm # find invisible octants if oct0 == - 1 : hide_oct = [ ] elif oct0 < oct1 or oct0 == oct1 and _octant_gte ( oct0 , coo1 , coo0 ) : hide_oct = list ( range ( 0 , oct0 ) ) + list ( range ( oct1 + 1 , 8 ) ) else : hide_oct = list ( range ( oct1 + 1 , oct0 ) ) # if oct1==oct0: # ----|.....|--- : coo1 lt coo0 : print if y in [0,coo1] or in [coo0, r] # ....|-----|... ; coo1 gte coo0: print if y in [coo0,coo1] x , y = r , 0 bres_error = 1 - r while x >= y : for octant in range ( 0 , 8 ) : if octant in hide_oct : continue elif oct0 != oct1 and octant == oct0 and _octant_gt ( oct0 , coo0 , y ) : continue elif oct0 != oct1 and octant == oct1 and _octant_gt ( oct1 , y , coo1 ) : continue elif oct0 == oct1 and octant == oct0 : # if coo1 >= coo0 if _octant_gte ( oct0 , coo1 , coo0 ) : # if y > coo1 or y < coo0 # (don't draw if y is outside coo's) if _octant_gt ( oct0 , y , coo1 ) or _octant_gt ( oct0 , coo0 , y ) : continue else : # if coo0 > y > c001 # (don't draw if y is between coo's) if _octant_gt ( oct0 , y , coo1 ) and _octant_gt ( oct0 , coo0 , y ) : continue oct_x , oct_y = _octant_coord ( octant , x0 , y0 , x , y ) self . graph_view [ oct_y , oct_x ] = attr # remember endpoints for pie sectors if y == coo0 : coo0x = x if y == coo1 : coo1x = x # bresenham error step y += 1 if bres_error < 0 : bres_error += 2 * y + 1 else : x -= 1 bres_error += 2 * ( y - x + 1 ) # draw pie-slice lines if line0 : self . _draw_line ( x0 , y0 , * _octant_coord ( oct0 , x0 , y0 , coo0x , coo0 ) , attr = attr ) if line1 : self . _draw_line ( x0 , y0 , * _octant_coord ( oct1 , x0 , y0 , coo1x , coo1 ) , attr = attr )