Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
surface.blit(img, (x, y))
column += 1
charIdx += 1
if widget.editable and row == widget.cursorRow and \
widget.focused and widget.app.cursorOn and \
column == widget.cursorColumn:
pygame.draw.line(surface, foreground, (newX, y), (newX, y + img.get_height()), 1)
x = newX
# draw cursor in case of zero lenght paragraph or begining of line
if (len(para) == 0 or widget.cursorColumn == 0) and \
widget.editable and row == widget.cursorRow and \
widget.focused and widget.app.cursorOn:
pygame.draw.line(surface, foreground, (r.left, firstY), (r.left, firstY + img.get_height()), 1)
x = r.left
y += img.get_height()
row += 1
line += 1
if y + img.get_height() > r.bottom:
surface.set_clip(oldClip)
return
surface.set_clip(oldClip)
def drawBox(self, box): #being added but not drawn, not Key erroring either
try:
self.nodes[box]
except KeyError:
return
colour = 0xaaaaaa
if box == self.selected :
colour = 0xff8888
print self.display, colour, self.boxes[box], self.boxsize
pygame.draw.rect(self.display, colour, (self.boxes[box],self.boxsize), 0)
cx = self.boxes[box][0]+self.boxsize[0]/2
cy = self.boxes[box][1]+self.boxsize[1]/2
image, w,h = self.makeLabel(self.nodes[box])
self.display.blit( image, (cx-w/2,cy-h/2) )
if box.children:
self.drawTree(box)
def draw_key2():
y_scaling = int(float(height-20)/no_of_species_per_patch)
i = 0
for species in ocean.data[0][current_patch].species:
pygame.draw.line(screen, species.colour, [width-10, 10 + i*y_scaling],[width, 10 + i*y_scaling],5)
label = myfont.render(str(species.number), 1, (0,0,0))
screen.blit(label, [width-30, 5 + i*y_scaling])
i += 1
def draw_main_board(self):
# Main board size = 400 x 400
# Game board size = 320 x 320
mainboard_rect = pygame.Rect(MARGIN, TOP_MARGIN, WINDOW_WIDTH -
2 * MARGIN, WINDOW_WIDTH - 2 * MARGIN)
pygame.draw.rect(DISPLAYSURF, BADUK, mainboard_rect)
# Horizontal Lines
for i in range(GAMEBOARD_SIZE):
pygame.draw.line(DISPLAYSURF, BLACK, (MARGIN + BOARD_MARGIN, TOP_MARGIN + BOARD_MARGIN + i * int(GRID_SIZE / (GAMEBOARD_SIZE - 1))),
(WINDOW_WIDTH - (MARGIN + BOARD_MARGIN), TOP_MARGIN + BOARD_MARGIN + i * int(GRID_SIZE / (GAMEBOARD_SIZE - 1))), 1)
# Vertical Lines
for i in range(GAMEBOARD_SIZE):
pygame.draw.line(DISPLAYSURF, BLACK, (MARGIN + BOARD_MARGIN + i * int(GRID_SIZE / (GAMEBOARD_SIZE - 1)), TOP_MARGIN + BOARD_MARGIN),
(MARGIN + BOARD_MARGIN + i * int(GRID_SIZE / (GAMEBOARD_SIZE - 1)), TOP_MARGIN + BOARD_MARGIN + GRID_SIZE), 1)
# Draw center circle
pygame.draw.circle(DISPLAYSURF, BLACK, (MARGIN + BOARD_MARGIN + 7 * int(GRID_SIZE / (
GAMEBOARD_SIZE - 1)), TOP_MARGIN + BOARD_MARGIN + 7 * int(GRID_SIZE / (GAMEBOARD_SIZE - 1))), 5, 0)
# Draw stones
def drawLine(self, line):
pygame.draw.line(self.display, 0,line[0],line[1],2)
(x+25, y-8),
(x+23, y-12),
(x+20, y-14),
(x+18, y-15),
(x+15, y-17),
(x+13, y-19),
(x+11, y-21)
]
pygame.draw.circle(gameDisplay, black, (x,y), int(tankHeight/2))
pygame.draw.rect(gameDisplay, black, (x-tankHeight, y, tankWidth, tankHeight))
pygame.draw.line(gameDisplay, black, (x,y), possibleTurrets[turPos], turretWidth)
pygame.draw.circle(gameDisplay, black, (x-15, y+20), wheelWidth)
pygame.draw.circle(gameDisplay, black, (x-10, y+20), wheelWidth)
pygame.draw.circle(gameDisplay, black, (x-15, y+20), wheelWidth)
pygame.draw.circle(gameDisplay, black, (x-10, y+20), wheelWidth)
pygame.draw.circle(gameDisplay, black, (x-5, y+20), wheelWidth)
pygame.draw.circle(gameDisplay, black, (x, y+20), wheelWidth)
pygame.draw.circle(gameDisplay, black, (x+5, y+20), wheelWidth)
pygame.draw.circle(gameDisplay, black, (x+10, y+20), wheelWidth)
pygame.draw.circle(gameDisplay, black, (x+15, y+20), wheelWidth)
return possibleTurrets[turPos]
def draw_stick_figure(screen, x, y):
# Head
pygame.draw.ellipse(screen, BLACK, [1 + x, y, 10, 10], 0)
# Legs
pygame.draw.line(screen, BLACK, [5 + x, 17 + y], [10 + x, 27 + y], 2)
pygame.draw.line(screen, BLACK, [5 + x, 17 + y], [x, 27 + y], 2)
# Body
pygame.draw.line(screen, RED, [5 + x, 17 + y], [5 + x, 7 + y], 2)
# Arms
pygame.draw.line(screen, RED, [5 + x, 7 + y], [9 + x, 17 + y], 2)
pygame.draw.line(screen, RED, [5 + x, 7 + y], [1 + x, 17 + y], 2)
def drawcircle(self, s, color, x, y, radius):
"""
draws a circle to the surface s and fixes the borders
pygame.draw.circle has a bug: there are some pixels where
they don't belong. This function stores the values and
restores them
"""
p1 = self._savepixel(x-1, y-radius-1, s)
p2 = self._savepixel(x, y-radius-1, s)
p3 = self._savepixel(x+1, y-radius-1, s)
p4 = self._savepixel(x-1, y+radius, s)
p5 = self._savepixel(x, y+radius, s)
p6 = self._savepixel(x+1, y+radius, s)
pygame.draw.circle(s, color, (x, y), radius)
self._restorepixel(p1, s)
self._restorepixel(p2, s)
self._restorepixel(p3, s)
self._restorepixel(p4, s)
self._restorepixel(p5, s)
self._restorepixel(p6, s)
def CreateCircle(self, color=(255, 255, 255, 255), radius=50, invisible=False):
"""Create(draw) a circle surface."""
if not invisible:
self.image = pygame.Surface((radius*2, radius*2),pygame.SRCALPHA)
pygame.draw.circle(self.image, color, (radius,radius), radius)
self.image = self.image.convert_alpha()
else:
self.image = pygame.Surface([radius*2, radius*2], pygame.SRCALPHA, 32)
pygame.draw.circle(self.image, pygame.SRCALPHA, (radius,radius), radius)
self.image = self.image.convert_alpha()
self.current_image = self.image
self.surface = pygame.Surface(self.current_image.get_size(), pygame.SRCALPHA, 32)
self.rect = self.image.get_rect()
def create_circle(self, color=(255, 255, 255, 255), radius=50, invisible=False):
def border():
pygame.draw.rect(display, gray, (0, 0, width, 30))
pygame.draw.rect(display, gray, (0, 0, 30, height))
pygame.draw.rect(display, gray, (width - 30, 0, width, height))
pygame.draw.rect(display, gray, (0, height - 30, width, height))