def filledSquare(x, y, r):
    global _surface
    """
    Draw on the surface a filled square whose sides are of length 2r,
    centered on (x, y).
    """
    ws = stddraw._factorX(2*r)
    hs = stddraw._factorY(2*r)
    if (ws <= 1) and (hs <= 1):
        stddraw._pixel(x, y)
    else:
        xs = stddraw._scaleX(x)
        ys = stddraw._scaleY(y)    
        filledRectangle(x, y, r, r)
Exemple #2
0
def filledSquare(x, y, r):
    global _surface
    """
    Draw on the surface a filled square whose sides are of length 2r,
    centered on (x, y).
    """
    ws = stddraw._factorX(2 * r)
    hs = stddraw._factorY(2 * r)
    if (ws <= 1) and (hs <= 1):
        stddraw._pixel(x, y)
    else:
        xs = stddraw._scaleX(x)
        ys = stddraw._scaleY(y)
        filledRectangle(x, y, r, r)
Exemple #3
0
def circle(x, y, r):
    """
    Draw on the surface a circle of radius r centered on (x, y).
    """
    global _surface

    ws = stddraw._factorX(2 * r)
    hs = stddraw._factorY(2 * r)
    if (ws <= 1) and (hs <= 1):
        stddraw._pixel(x, y)
    else:
        xs = stddraw._scaleX(x)
        ys = stddraw._scaleY(y)
        pygame.draw.ellipse(_surface, stddraw.pygameColor(stddraw.BLACK),
                            pygame.Rect(xs - ws / 2, ys - hs / 2, ws, hs), 1)
def filledCircle(x, y, r):
    """
    Draw on the surface a filled circle of radius r centered on (x, y).
    """
    global _surface
    ws = stddraw._factorX(2*r)
    hs = stddraw._factorY(2*r)
    if (ws <= 1) and (hs <= 1):
        stddraw._pixel(x, y)
    else:
        xs = stddraw._scaleX(x)
        ys = stddraw._scaleY(y)
        pygame.draw.ellipse(_surface,
            stddrawpygameColor(stddraw.BLACK),
            pygame.Rect(xs-ws/2, ys-hs/2, ws, hs),
            0)
        _draw()
Exemple #5
0
def filledRectangle(x, y, w, h):
    """
    Draw on the surface a filled rectangle of width w and height h,
    centered on (x, y).
    """
    global _surface
    ws = stddraw._factorX(2 * w)
    hs = stddraw._factorY(2 * h)
    if (ws <= 1) and (hs <= 1):
        stddraw._pixel(x, y)
    else:
        xs = stddraw._scaleX(x)
        ys = stddraw._scaleY(y)
        pygame.draw.rect(_surface,
                         pygameColor(stddraw.pygameColor(stddraw.GRAY)),
                         pygame.Rect(xs - ws / 2, ys - hs / 2, ws, hs), 0)
        _draw()
def filledRectangle(x, y, w, h):
    """
    Draw on the surface a filled rectangle of width w and height h,
    centered on (x, y).
    """
    global _surface
    ws = stddraw._factorX(2*w)
    hs = stddraw._factorY(2*h)
    if (ws <= 1) and (hs <= 1):
        stddraw._pixel(x, y)
    else:
        xs = stddraw._scaleX(x)
        ys = stddraw._scaleY(y)
        pygame.draw.rect(_surface,
            pygameColor(stddraw.pygameColor(stddraw.GRAY)),
            pygame.Rect(xs-ws/2, ys-hs/2, ws, hs),
            0)
        _draw()