def drawIcon(ren, shape, color, boxx, boxy): quarter = int(BOXSIZE * 0.25) # syntactic sugar half = int(BOXSIZE * 0.5) # syntactic sugar left, top = leftTopCoordsOfBox(boxx, boxy) # get pixel coords from board coords # Draw the shapes if shape == DONUT: sdlgfx.filledCircleRGBA(ren.renderer, left + half, top + half, half - 5, *color) sdlgfx.filledCircleRGBA(ren.renderer, left + half, top + half, quarter - 5, *BGCOLOR) elif shape == SQUARE: lqrtr = left + quarter tqrtr = top + quarter sdlgfx.boxRGBA(ren.renderer, lqrtr, tqrtr, lqrtr + BOXSIZE - half, tqrtr + BOXSIZE - half, *color) elif shape == DIAMOND: pts = ((left + half, top), (left + BOXSIZE - 1, top + half), (left + half, top + BOXSIZE - 1), (left, top + half)) draw_polygon(ren.renderer, pts, color) elif shape == LINES: for i in range(0, BOXSIZE, 4): ren.draw_line((left, top + i, left + i, top), color) ren.draw_line( (left + i, top + BOXSIZE - 1, left + BOXSIZE - 1, top + i), color) elif shape == OVAL: sdlgfx.ellipseRGBA(ren.renderer, left + BOXSIZE // 2, top + quarter + half // 2, BOXSIZE // 2, half // 2, *color)
def draw_shapes(): context.clear(WHITE) sdlgfx.filledPolygonRGBA(context.renderer, xarray, yarray, ptcnt, *GREEN) sdlgfx.filledCircleRGBA(context.renderer, 300, 50, 20, *BLUE) sdlgfx.ellipseRGBA(context.renderer, 320, 240, 20, 40, *RED) sdlgfx.boxRGBA(context.renderer, 200, 150, 300, 200, *RED) sdlgfx.thickLineRGBA(context.renderer, 60, 60, 120, 60, 4, *BLUE) sdlgfx.lineRGBA(context.renderer, 120, 60, 60, 120, *BLUE) sdlgfx.thickLineRGBA(context.renderer, 60, 120, 120, 120, 4, *BLUE) points = [380, 280, 382, 282, 384, 284, 386, 286, 388, 288] context.draw_point(points, BLACK)
def drawIcon(ren, shape, color, boxx, boxy): quarter = int(BOXSIZE * 0.25) # syntactic sugar half = int(BOXSIZE * 0.5) # syntactic sugar left, top = leftTopCoordsOfBox(boxx, boxy) # get pixel coords from board coords # Draw the shapes if shape == DONUT: sdlgfx.filledCircleRGBA(ren.renderer, left+half, top+half, half-5, *color) sdlgfx.filledCircleRGBA(ren.renderer, left+half, top+half, quarter-5, *BGCOLOR) elif shape == SQUARE: lqrtr = left+quarter tqrtr = top+quarter sdlgfx.boxRGBA(ren.renderer, lqrtr, tqrtr, lqrtr+BOXSIZE-half, tqrtr+BOXSIZE-half, *color) elif shape == DIAMOND: pts = ((left + half, top), (left + BOXSIZE - 1, top + half), (left + half, top + BOXSIZE - 1), (left, top + half)) draw_polygon(ren.renderer, pts, color) elif shape == LINES: for i in range(0, BOXSIZE, 4): ren.draw_line((left, top+i, left+i, top), color) ren.draw_line((left+i, top+BOXSIZE-1, left+BOXSIZE-1, top+i), color) elif shape == OVAL: sdlgfx.ellipseRGBA(ren.renderer, left+BOXSIZE//2, top+quarter+half//2, BOXSIZE//2, half//2, *color)