Exemplo n.º 1
0
def draw_circles(context, width, height):
    # Reset the visible area with a black color.
    context.clear(0)
    # Split the visible area
    wthird = width // 3 - 1
    lw = 3
    sdlgfx.thickLineColor(context.renderer, wthird, 0, wthird, height, lw,
                          0xFFFFFFFF)
    sdlgfx.thickLineColor(context.renderer, (2 * wthird + lw), 0,
                          (2 * wthird + lw), height, lw, 0xFFFFFFFF)
    for x in range(15):
        # In the first part, draw circles
        color = randint(0, 0xFFFFFFFF)
        x, y = randint(0, wthird), randint(0, height)
        r = randint(1, max(min(x, wthird - x), 2))
        sdlgfx.circleColor(context.renderer, x, y, r, color)
        # In the second part, draw aa circles
        color = randint(0, 0xFFFFFFFF)
        x, y = randint(0, wthird), randint(0, height)
        r = randint(1, max(min(x, wthird - x), 2))
        sdlgfx.aacircleColor(context.renderer, x + wthird + lw, y, r, color)
        # In the third part, draw filled circles
        color = randint(0, 0xFFFFFFFF)
        x, y = randint(0, wthird), randint(0, height)
        r = randint(1, max(min(x, wthird - x), 2))
        sdlgfx.filledCircleColor(context.renderer, x + 2 * (wthird + lw), y, r,
                                 color)
Exemplo n.º 2
0
def draw_ellipsis(context, width, height):
    # Reset the visible area with a black color.
    context.clear(0)
    # Split the visible area
    wthird = width // 3 - 1
    eheight = height // 4
    lw = 3
    sdlgfx.thickLineColor(context.renderer, wthird, 0, wthird, height, lw,
                          0xFFFFFFFF)
    sdlgfx.thickLineColor(context.renderer, (2 * wthird + lw), 0,
                          (2 * wthird + lw), height, lw, 0xFFFFFFFF)
    for x in range(15):
        # In the first part, draw ellipsis
        color = randint(0, 0xFFFFFFFF)
        x, y = randint(0, wthird), randint(0, height)
        rx, ry = randint(1, max(min(x, wthird - x), 2)), randint(0, eheight)
        sdlgfx.ellipseColor(context.renderer, x, y, rx, ry, color)
        # In the second part, draw aa ellipsis
        color = randint(0, 0xFFFFFFFF)
        x, y = randint(0, wthird), randint(0, height)
        rx, ry = randint(1, max(min(x, wthird - x), 2)), randint(0, eheight)
        sdlgfx.aaellipseColor(context.renderer, x + wthird + lw, y, rx, ry,
                              color)
        # In the third part, draw filled ellipsis
        color = randint(0, 0xFFFFFFFF)
        x, y = randint(0, wthird), randint(0, height)
        rx, ry = randint(1, max(min(x, wthird - x), 2)), randint(0, eheight)
        sdlgfx.filledEllipseColor(context.renderer, x + 2 * (wthird + lw), y,
                                  rx, ry, color)
Exemplo n.º 3
0
def draw_lines(context, width, height):
    # Reset the visible area with a black color.
    context.clear(0)
    # Split the visible area
    whalf = width // 2 - 2
    hhalf = height // 2 - 2
    lw = 5
    x0, x1 = whalf, whalf
    y0, y1 = 0, height
    sdlgfx.thickLineColor(context.renderer, x0, y0, x1, y1, lw, 0xFFFFFFFF)
    x0, x1 = 0, width
    y0, y1 = hhalf, hhalf
    sdlgfx.thickLineColor(context.renderer, x0, y0, x1, y1, lw, 0xFFFFFFFF)
    for x in range(15):
        # In the first quadrant, draw normal lines
        color = randint(0, 0xFFFFFFFF)
        x0, x1 = randint(0, whalf), randint(0, whalf)
        y0, y1 = randint(0, hhalf), randint(0, hhalf)
        sdlgfx.lineColor(context.renderer, x0, y0, x1, y1, color)
        # In the second quadrant, draw aa lines
        color = randint(0, 0xFFFFFFFF)
        x0, x1 = randint(whalf + lw, width), randint(whalf + lw, width)
        y0, y1 = randint(0, hhalf), randint(0, hhalf)
        sdlgfx.aalineColor(context.renderer, x0, y0, x1, y1, color)
        # In the third quadrant, draw horizontal lines
        color = randint(0, 0xFFFFFFFF)
        x0, x1 = randint(0, whalf), randint(0, whalf)
        y0 = randint(hhalf + lw, height)
        sdlgfx.hlineColor(context.renderer, x0, x1, y0, color)
        # In the fourth quadrant, draw vertical lines
        color = randint(0, 0xFFFFFFFF)
        x0 = randint(whalf + lw, width)
        y0, y1 = randint(hhalf + lw, height), randint(hhalf + lw, height)
        sdlgfx.vlineColor(context.renderer, x0, y0, y1, color)
Exemplo n.º 4
0
def draw_trigons(context, width, height):
    # Reset the visible area with a black color.
    context.clear(0)
    # Split the visible area
    wthird = width // 3 - 1
    lw = 3
    sdlgfx.thickLineColor(context.renderer, wthird, 0, wthird, height, lw,
                          0xFFFFFFFF)
    sdlgfx.thickLineColor(context.renderer, (2 * wthird + lw), 0,
                          (2 * wthird + lw), height, lw, 0xFFFFFFFF)
    for x in range(15):
        # In the first part, draw triangles
        color = randint(0, 0xFFFFFFFF)
        x0, y0 = randint(0, wthird), randint(0, height)
        x1, y1 = randint(0, wthird), randint(0, height)
        x2, y2 = randint(0, wthird), randint(0, height)
        sdlgfx.trigonColor(context.renderer, x0, y0, x1, y1, x2, y2, color)
        # In the second part, draw aa triangles
        color = randint(0, 0xFFFFFFFF)
        x0, y0 = randint(0, wthird) + wthird + lw, randint(0, height)
        x1, y1 = randint(0, wthird) + wthird + lw, randint(0, height)
        x2, y2 = randint(0, wthird) + wthird + lw, randint(0, height)
        sdlgfx.aatrigonColor(context.renderer, x0, y0, x1, y1, x2, y2, color)
        # In the third part, draw filled triangles
        color = randint(0, 0xFFFFFFFF)
        x0, y0 = randint(0, wthird) + 2 * (wthird + lw), randint(0, height)
        x1, y1 = randint(0, wthird) + 2 * (wthird + lw), randint(0, height)
        x2, y2 = randint(0, wthird) + 2 * (wthird + lw), randint(0, height)
        sdlgfx.filledTrigonColor(context.renderer, x0, y0, x1, y1, x2, y2,
                                 color)
Exemplo n.º 5
0
def draw_mixed(context, width, height):
    # Reset the visible area with a black color.
    context.clear(0)
    # Split the visible area
    whalf = width // 2 - 2
    hhalf = height // 2 - 2
    lw = 5
    x0, x1 = whalf, whalf
    y0, y1 = 0, height
    sdlgfx.thickLineColor(context.renderer, x0, y0, x1, y1, lw, 0xFFFFFFFF)
    x0, x1 = 0, width
    y0, y1 = hhalf, hhalf
    sdlgfx.thickLineColor(context.renderer, x0, y0, x1, y1, lw, 0xFFFFFFFF)
    for x in range(15):
        # In the first quadrant, draw arcs
        color = randint(0, 0xFFFFFFFF)
        x0, y0 = randint(0, whalf), randint(0, hhalf)
        rad = randint(0, min(whalf - x0, hhalf - y0))
        start, end = randint(0, 360), randint(0, 360)
        sdlgfx.arcColor(context.renderer, x0, y0, rad, start, end, color)
        # In the second quadrant, draw bezier curves
        color = randint(0, 0xFFFFFFFF)
        ptcount = randint(3, 10)
        xlist, ylist = (Sint16 * ptcount)(), (Sint16 * ptcount)()
        for k in range(ptcount):
            xlist[k] = randint(whalf, width)
            ylist[k] = randint(0, hhalf)
        steps = randint(2, 10)
        xptr = ctypes.cast(xlist, ctypes.POINTER(Sint16))
        yptr = ctypes.cast(ylist, ctypes.POINTER(Sint16))
        sdlgfx.bezierColor(context.renderer, xptr, yptr, ptcount, steps, color)
        # In the third quadrant, draw pies
        color = randint(0, 0xFFFFFFFF)
        x0, y0 = randint(0, whalf), randint(hhalf + lw, height)
        rad = randint(0, min(whalf - x0, y0 - (hhalf + lw)))
        start, end = randint(0, 360), randint(0, 360)
        sdlgfx.pieColor(context.renderer, x0, y0, rad, start, end, color)
        # In the fourth quadrant, draw filled pies
        color = randint(0, 0xFFFFFFFF)
        x0, y0 = randint(whalf + lw, width), randint(hhalf + lw, height)
        rad = randint(0, min(x0 - (whalf + lw), y0 - (hhalf + lw)))
        start, end = randint(0, 360), randint(0, 360)
        sdlgfx.filledPieColor(context.renderer, x0, y0, rad, start, end, color)
Exemplo n.º 6
0
def draw_polygons(context, width, height):
    # Reset the visible area with a black color.
    context.clear(0)
    # Split the visible area
    wthird = width // 3 - 1
    lw = 3
    sdlgfx.thickLineColor(context.renderer, wthird, 0, wthird, height, lw,
                          0xFFFFFFFF)
    sdlgfx.thickLineColor(context.renderer, (2 * wthird + lw), 0,
                          (2 * wthird + lw), height, lw, 0xFFFFFFFF)
    for x in range(5):
        # In the first part, draw polygons
        color = randint(0, 0xFFFFFFFF)
        ptcount = randint(3, 10)
        xlist, ylist = (Sint16 * ptcount)(), (Sint16 * ptcount)()
        for k in range(ptcount):
            xlist[k] = randint(0, wthird)
            ylist[k] = randint(0, height)
        xptr = ctypes.cast(xlist, ctypes.POINTER(Sint16))
        yptr = ctypes.cast(ylist, ctypes.POINTER(Sint16))
        sdlgfx.polygonColor(context.renderer, xptr, yptr, ptcount, color)
        # In the second part, draw aa polygons
        color = randint(0, 0xFFFFFFFF)
        ptcount = randint(3, 10)
        xlist, ylist = (Sint16 * ptcount)(), (Sint16 * ptcount)()
        for k in range(ptcount):
            xlist[k] = randint(0, wthird) + wthird + lw
            ylist[k] = randint(0, height)
        xptr = ctypes.cast(xlist, ctypes.POINTER(Sint16))
        yptr = ctypes.cast(ylist, ctypes.POINTER(Sint16))
        sdlgfx.aapolygonColor(context.renderer, xptr, yptr, ptcount, color)
        # In the third part, draw filled polygons
        color = randint(0, 0xFFFFFFFF)
        ptcount = randint(3, 10)
        xlist, ylist = (Sint16 * ptcount)(), (Sint16 * ptcount)()
        for k in range(ptcount):
            xlist[k] = randint(0, wthird) + 2 * (wthird + lw)
            ylist[k] = randint(0, height)
        xptr = ctypes.cast(xlist, ctypes.POINTER(Sint16))
        yptr = ctypes.cast(ylist, ctypes.POINTER(Sint16))
        sdlgfx.filledPolygonColor(context.renderer, xptr, yptr, ptcount, color)
Exemplo n.º 7
0
def draw_rects(context, width, height):
    # Reset the visible area with a black color.
    context.clear(0)
    # Split the visible area
    whalf = width // 2 - 2
    hhalf = height // 2 - 2
    lw = 5
    x0, x1 = whalf, whalf
    y0, y1 = 0, height
    sdlgfx.thickLineColor(context.renderer, x0, y0, x1, y1, lw, 0xFFFFFFFF)
    x0, x1 = 0, width
    y0, y1 = hhalf, hhalf
    sdlgfx.thickLineColor(context.renderer, x0, y0, x1, y1, lw, 0xFFFFFFFF)
    for x in range(15):
        # In the first quadrant, draw normal rectangles
        color = randint(0, 0xFFFFFFFF)
        x0, x1 = randint(0, whalf), randint(0, whalf)
        y0, y1 = randint(0, hhalf), randint(0, hhalf)
        sdlgfx.rectangleColor(context.renderer, x0, y0, x1, y1, color)
        # In the second quadrant, draw rounded rectangles
        color = randint(0, 0xFFFFFFFF)
        x0, x1 = randint(whalf + lw, width), randint(whalf + lw, width)
        y0, y1 = randint(0, hhalf), randint(0, hhalf)
        r = randint(0, max(x1 - x0, x0 - x1))
        sdlgfx.roundedRectangleColor(context.renderer, x0, y0, x1, y1, r,
                                     color)
        # In the third quadrant, draw horizontal lines
        color = randint(0, 0xFFFFFFFF)
        x0, x1 = randint(0, whalf), randint(0, whalf)
        y0, y1 = randint(hhalf + lw, height), randint(hhalf + lw, height)
        sdlgfx.boxColor(context.renderer, x0, y0, x1, y1, color)
        # In the fourth quadrant, draw vertical lines
        color = randint(0, 0xFFFFFFFF)
        x0, x1 = randint(whalf + lw, width), randint(whalf + lw, width)
        y0, y1 = randint(hhalf + lw, height), randint(hhalf + lw, height)
        r = randint(1, max(x1 - x0, x0 - x1))
        sdlgfx.roundedBoxColor(context.renderer, x0, y0, x1, y1, r, color)