コード例 #1
0
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)
コード例 #2
0
def animateTileChange(tilesToFlip, tileColor, additionalTile):
	# Draw the additional tile that was just laid down. (Otherwise we'd
	# have to completely redraw the board & the board info.)
	if tileColor == WHITE_TILE:
		additionalTileColor = WHITE
	else:
		additionalTileColor = BLACK
	additionalTileX, additionalTileY = translateBoardToPixelCoord(additionalTile[0], additionalTile[1])
	sdlgfx.filledCircleRGBA(REN.renderer, additionalTileX, additionalTileY, SPACESIZE//2 - 4, *additionalTileColor)
	REN.present()

	for rgbValues in range(0, 255, int(ANIMATIONSPEED * 2.55)):
		for event in ext.get_events():
			if event.type == SDL_QUIT:
				shutdown()
			elif event.type == SDL_KEYUP:
				sc = event.key.keysym.scancode
				if sc == SDL_SCANCODE_ESCAPE:
					shutdown()

		if rgbValues > 255:
			rgbValues = 255
		elif rgbValues < 0:
			rgbValues = 0

		if tileColor == WHITE_TILE:
			color = (rgbValues, rgbValues, rgbValues, 255) # rgbValues goes from 0 to 255
		elif tileColor == BLACK_TILE:
			color = (255 - rgbValues, 255 - rgbValues, 255 - rgbValues, 255) # rgbValues goes from 255 to 0

		for x, y in tilesToFlip:
			centerx, centery = translateBoardToPixelCoord(x, y)
			sdlgfx.filledCircleRGBA(REN.renderer, centerx, centery, SPACESIZE//2 - 4, *color)
		REN.present()
		SDL_Delay(1000//FPS)
コード例 #3
0
def drawBoard(board):
	# Draw background of board.
	SPRITE_RENDERER.render(BG_SPR) # sprite position set to 0, 0 in constructor

	# Draw grid lines of the board.
	for x in range(BOARDWIDTH + 1):
		# Draw the horizontal lines.
		startx = (x * SPACESIZE) + XMARGIN
		starty = YMARGIN
		endx = (x * SPACESIZE) + XMARGIN
		endy = YMARGIN + (BOARDHEIGHT * SPACESIZE)
		REN.draw_line((startx, starty, endx, endy), GRIDLINECOLOR)
	for y in range(BOARDHEIGHT + 1):
		# Draw the vertical lines.
		startx = XMARGIN
		starty = (y * SPACESIZE) + YMARGIN
		endx = XMARGIN + (BOARDWIDTH * SPACESIZE)
		endy = (y * SPACESIZE) + YMARGIN
		REN.draw_line((startx, starty, endx, endy), GRIDLINECOLOR)

	# Draw the black & white tiles or hint spots.
	for x in range(BOARDWIDTH):
		for y in range(BOARDHEIGHT):
			centerx, centery = translateBoardToPixelCoord(x, y)
			if board[x][y] == WHITE_TILE or board[x][y] == BLACK_TILE:
				if board[x][y] == WHITE_TILE:
					tileColor = WHITE
				else:
					tileColor = BLACK
				sdlgfx.filledCircleRGBA(REN.renderer, centerx, centery, SPACESIZE//2 - 4, *tileColor) 
			if board[x][y] == HINT_TILE:
				REN.fill((centerx-4, centery-4, 8, 8), HINTCOLOR)
コード例 #4
0
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)
コード例 #5
0
def draw_circle(surface, x, y, rad, colour=(0, 0, 0, 0), Filled=True):

    if len(colour) == 3:
        colour = (colour[0] % 256, colour[1] % 256, colour[2] % 256, 255)
    elif len(colour) == 4:
        colour = (colour[0] % 256, colour[1] % 256, colour[2] % 256,
                  colour[3] % 256)

    if Filled:
        gfx.filledCircleRGBA(surface.renderer, x, y, rad, colour[0], colour[1],
                             colour[2], colour[3])

    else:
        gfx.circleRGBA(surface.renderer, x, y, rad, colour[0], colour[1],
                       colour[2], colour[3])
コード例 #6
0
    def raw_circle_solid(self, circle, color):
        self._no_error(
            gfx.filledCircleRGBA(self._renderer, trunc(circle.x),
                                 trunc(self.height - circle.y),
                                 trunc(circle.radius), *color))

        self._no_error(
            gfx.aacircleRGBA(self._renderer, trunc(circle.x),
                             trunc(self.height - circle.y),
                             trunc(circle.radius), *color))
コード例 #7
0
ファイル: sdl2_be.py プロジェクト: diegor2/FGAme
    def draw_raw_circle_solid(self, circle, color):
        self._no_error(
            gfx.filledCircleRGBA(
                self._renderer, trunc(circle.x), trunc(self.height - circle.y), trunc(circle.radius), *color
            )
        )

        self._no_error(
            gfx.aacircleRGBA(
                self._renderer, trunc(circle.x), trunc(self.height - circle.y), trunc(circle.radius), *color
            )
        )
コード例 #8
0
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)
コード例 #9
0
ファイル: sdl2_be.py プロジェクト: gutioliveira/FGAme
    def raw_circle_solid(self, circle, color=None):
        self._no_error(
            gfx.filledCircleRGBA(
                self._renderer,
                trunc(circle.x),
                trunc(self.height - circle.y),
                trunc(circle.radius), *(color or self._black)))

        self._no_error(
            gfx.aacircleRGBA(
                self._renderer,
                trunc(circle.x),
                trunc(self.height - circle.y),
                trunc(circle.radius), *color))
コード例 #10
0
def fill_circle(renderer, x, y, color=lib.Color(255, 255, 255)):
    gfx.filledCircleRGBA(renderer.sdlrenderer,
                         x * grid_cell_size + int(grid_cell_size / 2) + 1,
                         y * grid_cell_size + int(grid_cell_size / 2) + 1,
                         int(grid_cell_size / 4), color.r, color.g, color.b,
                         color.a)
コード例 #11
0
 def render(self, xy):
     filledCircleRGBA(window.renderer.sdlrenderer, xy[0] + self.radius,
                      xy[1] + self.radius, self.radius, self.color.rgba[0],
                      self.color.rgba[1], self.color.rgba[2],
                      self.color.rgba[3])