本文整理汇总了Python中pygame.draw.polygon函数的典型用法代码示例。如果您正苦于以下问题:Python polygon函数的具体用法?Python polygon怎么用?Python polygon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了polygon函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __draw_walls
def __draw_walls(self):
closed = [(x,y) for y in range(len(self.matrix)) for x in range(len(self.matrix[0]))
if not self.matrix[y][x]]
for c in closed:
x, y = c2r(c)
draw.polygon(self.window, (100, 50, 50),
[(x,y), (x + X_CELL, y), (x + X_CELL, y + Y_CELL), (x, y + Y_CELL)])
开发者ID:wannadie,项目名称:ideaman,代码行数:8,代码来源:location.py
示例2: paint
def paint(self, surface):
if not self.active:
return
point_list = self.get_points()
converted_point_list = []
for point in point_list:
converted_point_list.append(point.pair())
draw.polygon(surface, self.color, converted_point_list)
开发者ID:theDrake,项目名称:asteroids-py,代码行数:8,代码来源:shapes.py
示例3: __draw_menu_cursor
def __draw_menu_cursor(self, surface):
cursor_height = self.menu_items_pos[self.selected_index]
draw.polygon(surface, self.orange_color, [
(400, cursor_height),
(400, cursor_height + self.cursor * 2),
(400 + self.cursor, cursor_height + self.cursor)])
draw.polygon(surface, self.orange_color, [
(780, cursor_height),
(780, cursor_height + self.cursor * 2),
(780 - self.cursor, cursor_height + self.cursor)])
开发者ID:ngkolev,项目名称:snake,代码行数:10,代码来源:snakegui.py
示例4: draw_arrows
def draw_arrows(self, surf, i, rect):
m = self.margin
color = self.sel_color or self.fg_color
x, y = rect.midtop
pts = [(x - m, y - m), (x + m, y - m), (x, y)]
draw.polygon(surf, color, pts)
x, y = rect.midbottom
y -= 1
pts = [(x - m, y + m), (x + m, y + m), (x, y)]
draw.polygon(surf, color, pts)
开发者ID:wolmir,项目名称:cristina,代码行数:10,代码来源:multichoice.py
示例5: draw_item
def draw_item(self, item):
if item.role == "Woger":
#if hasattr(item, 'image'):
#self.window.display_surface.blit(
# item.image, self.camera.point_to_screen(item.body.position))
if item.body.velocity[0] < -0.1:
self.window.display_surface.blit(
item.image[0], self.camera.point_to_screen(item.body.position))
self.facing_right = 0
elif item.body.velocity[0] > 0.1:
self.window.display_surface.blit(
item.image[1], self.camera.point_to_screen(item.body.position))
self.facing_right = 1
else:
self.window.display_surface.blit(
item.image[self.facing_right], self.camera.point_to_screen(item.body.position))
elif item.role == "Bough":
#an_image = item.image[angle(item.body.angle)]
#Only 16 images in there. So we find the closest image for that angle.
# >>> 360 / 23
# 15
# >>> 0 / 23
# 0
# >>> 180 / 23
# 7
assert(len(item.image) == 16)
idx_for_angle = int(angle(item.body.angle) /23)
an_image = item.image[idx_for_angle]
## verts = item.shape.get_points()
## x,y = sum(v[0] for v in verts)/3, sum(v[1] for v in verts)/3
self.window.display_surface.blit(an_image,
## self.camera.point_to_screen((x,y)))
self.camera.point_to_screen(item.body.position))
elif item.role == "Owange":
if item.status == "Collided":
self.window.display_surface.blit(
item.image[0], self.camera.point_to_screen(item.body.position))
else:
self.window.display_surface.blit(
item.image[0], self.camera.point_to_screen(item.body.position))
elif item.role == "Cherry":
self.window.display_surface.blit(
item.image[0], self.camera.point_to_screen(item.body.position))
else:
# note: 80% of program execution time is in this clause
# particularly retrieving the item.verts
draw.polygon(
self.window.display_surface,
item.color,
self.camera.to_screen(item.verts), 0)
开发者ID:mjs,项目名称:ldnpydojo,代码行数:55,代码来源:render.py
示例6: redraw
def redraw(self):
self.pointlist = []
self.heights = []
if not self.pointlist:
self.generate_terrain(self.buffer.get_size())
if self.color:
draw.polygon(self.buffer, white, self.pointlist)
else:
draw.polygon(self.buffer, black, self.pointlist)
draw.lines(self.buffer, white, True, self.pointlist)
开发者ID:yeahpython,项目名称:black-and-white,代码行数:11,代码来源:main.py
示例7: __draw_view_cells
def __draw_view_cells(self, obj):
color = obj.color
if obj.mode is 'hunting':
color = (255, obj.color[1], obj.color[2])
for point in obj.view_cells:
tl = c2r(point)
tr = tl[0] + X_CELL, tl[1]
br = tr[0], tr[1] + Y_CELL
bl = br[0] - X_CELL, br[1]
draw.polygon(self.window, color, (tl, tr, br, bl), 1)
开发者ID:wannadie,项目名称:ideaman,代码行数:12,代码来源:location.py
示例8: render
def render(surface):
from pygame import draw
pts = []
gl.rotate(1.0/180*math.pi, 0.5 , 1 , 0.25);
#for pt in [(-160,-120,0),(-160,120,0),(160,120,0),(160,-120,0)]:
z = 0
for pt in [(-160,-120,z),(-160,120,z),(160,120, z),(160,-120, z)]:
tp = gl.trans_(pt);
# 画面の中心に移動
tp[0]+=320;
tp[1]+=240;
pts.append(tp);
draw.polygon(surface, (255,255,255), pts)
开发者ID:ledyba,项目名称:Super-PX-Chip,代码行数:13,代码来源:main.py
示例9: runGUI
def runGUI():
pygame.display.set_mode((800,600))
pygame.display.set_caption("Neuro Junk 2012/13")
screen = pygame.display.get_surface()
while True:
input(pygame.event.get())
screen.fill((0,0,0))
circle(screen, (255,255,255), (0,0), radius, 1)
line(screen, (255,255,255), point1, point2, 1)
polygon(screen, (255,255,255), outer_line, 2)
polygon(screen, (255,255,255), inner_line,2)
if intersectCircle(point1, point2, radius):
rect(screen, (0,255,0), Rect(600, 200, 100, 100), 0)
inn = changeField(inner_line, car)
out = changeField(outer_line, car)
csect = curSection(inn, out)
polygon(screen, (0,0,255), out, 2)
polygon(screen, (0,0,255), inn, 2)
rect(screen, (255,255,255), Rect(car.x-2, car.y-2, 4, 4), 0)
if csect is not None:
line(screen, (0,255,0), csect.inner_start, csect.inner_end, 1)
line(screen, (0,255,0), csect.outer_start, csect.outer_end, 1)
pygame.display.update()
开发者ID:barzuln,项目名称:junkie,代码行数:32,代码来源:idealline.py
示例10: draw_poly
def draw_poly(poly):
polygon = Polygon(poly.points)
if poly.orientation:
c = polygon.centroid.coords[0]
polygon = Polygon([rotate(p, c, -poly.orientation)
for p in polygon.exterior.coords])
c = polygon.centroid.coords[0]
p = poly.position
dx, dy = [p[i] - c[i] for i in range(2)]
draw.polygon(screen, (0,255,0),
[defloat(scale(offset(p, dx, dy)))
for p in polygon.exterior.coords],
1)
draw.circle(screen, (0,255,0),
defloat(scale(offset(c, dx, dy))),
3)
开发者ID:tps12,项目名称:Why-So-Spherious,代码行数:16,代码来源:Click.py
示例11: draw
def draw(self, screen):
halfw = self.width / 2
halfh = self.height / 2
x = self.x
y = self.y
# 1 4
# x
# 2 3
slope = 15
points = None
if self.side == Sides.LEFT:
points = (
(x - halfw, y + halfh + slope),
(x + halfw, y + halfh),
(x + halfw, y - halfh),
(x - halfw, y - halfh - slope)
)
elif self.side == Sides.RIGHT:
points = (
(x + halfw, y + halfh + slope),
(x - halfw, y + halfh),
(x - halfw, y - halfh),
(x + halfw, y - halfh - slope)
)
elif self.side == Sides.TOP:
points = (
(x - halfw - slope, y - halfh),
(x - halfw, y + halfh),
(x + halfw, y + halfh),
(x + halfw + slope, y - halfh)
)
elif self.side == Sides.BOT:
points = (
(x - halfw - slope, y + halfh),
(x - halfw, y - halfh),
(x + halfw, y - halfh),
(x + halfw + slope, y + halfh)
)
draw.polygon(
screen,
self.color,
points
)
开发者ID:mortie,项目名称:zonelauncher,代码行数:47,代码来源:Game.py
示例12: _draw_base
def _draw_base(self):
img = self._images["image"]
img.fill(self._parent_view._settings["col"])
img.fill((200,200,200), self.rect.inflate(-4, -4))
# Draw line in center
r = self.rect
start_pos = (3, r.centery) if self.xy == "y" else (r.centerx, 3)
end_pos = (r.w-4, r.centery) if self.xy == "y" else (r.centerx, r.h-4)
draw.line(img, (100,100,100), start_pos, end_pos)
# Draw arrows
if self.xy == "y":
points1 = ((3, r.h/4), (r.centerx, r.h/5-1), (r.w-3, r.h/4))
points2 = ((3, r.h*.75), (r.centerx, r.h*.8), (r.w-3, r.h*.75))
else:
points1 = ((r.w/4, 3), (r.w/5-1, r.centery), (r.w/4, r.h-3))
points2 = ((r.w*.75, 3), (r.w*.8, r.centery), (r.w*.75, r.h-3))
draw.polygon(img, (50,50,50), points1)
draw.polygon(img, (50,50,50), points2)
开发者ID:602p,项目名称:spacegame,代码行数:18,代码来源:scroll_box.py
示例13: draw_poly
def draw_poly(poly, surface, color=None, width=None):
polygon = orient_polygon(poly)
c = polygon.centroid.coords[0]
p = poly.position
dx, dy = [p[i] - c[i] for i in range(2)]
if color is None:
color = (0,255,0)
if width is None:
width = 1
draw.polygon(surface, color,
[defloat(scale(offset(p, dx, dy)))
for p in polygon.exterior.coords],
width)
if width:
draw.circle(surface, color,
defloat(scale(offset(c, dx, dy))),
3*width)
开发者ID:tps12,项目名称:Why-So-Spherious,代码行数:19,代码来源:Collide.py
示例14: _draw_base
def _draw_base(self):
# Frames around edge of button
x = min(self.image.get_size()) / 8
self._frame_lt = ((0,0), (self.rect.w,0), (self.rect.w-x,x),
(x,x), (x,self.rect.h-x), (0,self.rect.h))
self._frame_rb = ((self.rect.w,self.rect.h),
(0,self.rect.h), (x,self.rect.h-x),
(self.rect.w-x,self.rect.h-x),
(self.rect.w-x,x), (self.rect.w,0))
cols = {}
cols["image"] = self._settings["col"]
cols["over"] = [min(c*1.1, 255) for c in self._settings["col"]]
cols["down"] = [c*0.8 for c in self._settings["col"]]
for img in cols:
self._images[img].fill(cols[img])
# Draw a frame around the edges of the button
frame_lt_c = [min(c*1.3,255) for c in cols[img]]
frame_rb_c = [c*0.8 for c in cols[img]]
draw.polygon(self._images[img], frame_lt_c, self._frame_lt)
draw.polygon(self._images[img], frame_rb_c, self._frame_rb)
开发者ID:602p,项目名称:spacegame,代码行数:20,代码来源:button.py
示例15: _draw_shape_filled
def _draw_shape_filled(surface, shape):
"""Draw the shape on the given surface.
Arguments:
surface - drawing surface (an instance of pygame.Surface class);
shape - shape to draw (an instance of one of the shape classes
defined in shapes module);
Result:
bounding box, defined during the drawing;
"""
return draw.polygon(surface, SHAPE_COLOR, shape.get_vertices())
开发者ID:Durlabh08,项目名称:pytang,代码行数:11,代码来源:pytang.py
示例16: render
def render(surface):
surface.fill(black)
c = 0
for bv in world:
x, y = bv.position
if c >= len(colors):
colors.append(Color(randint(40, 255), randint(40, 255),
randint(40, 255)))
color = colors[c]
c += 1
for fv in bv:
s = fv.shape
st = fv.shape.type
if st == b2Shape.e_circle:
draw.circle(surface, color, (int(x*PPM), int(y*PPM)),
int(s.radius*PPM))
elif st == b2Shape.e_polygon:
transformed_verts = [bv.transform * v for v in s.vertices]
verts = [(v.x*PPM, v.y*PPM) for v in transformed_verts]
draw.polygon(surface, color, verts)
开发者ID:jwiggins,项目名称:physics,代码行数:21,代码来源:main.py
示例17: render_filled_poly
def render_filled_poly(turtle, string, i):
#print "render_filled_poly:", string, i ###
lturtle = turtle.clone(mirror = 1, enable_drawing = False)
rturtle = turtle.clone(mirror = -1, enable_drawing = False)
j = render_boundary(lturtle, rturtle, string, i, 1)
h = turtle.heading
lturtle.mirror_heading(h)
rturtle.mirror_heading(h)
render_boundary(lturtle, rturtle, string, j - 2, -1)
###points = [turtle.position] + lturtle.path + list(reversed(rturtle.path))
###draw.polygon(turtle.surface, fill_color, points)
###gfxdraw.bezier(turtle.surface, points, 10, fill_color) ###
###fill_bezier(turtle.surface, fill_color, points, bezier_steps)
pfirst = [turtle.position]
plast = [0.5 * (lturtle.path[-1] + rturtle.path[-1])]
side1 = pfirst + lturtle.path + plast
side2 = pfirst + rturtle.path + plast
points1 = calculate_multi_bezier(side1, bezier_steps)
points2 = calculate_multi_bezier(side2, bezier_steps)
points = points1 + list(reversed(points2))
draw.polygon(turtle.surface, lturtle.fill_color, points)
return j
开发者ID:wolmir,项目名称:cristina,代码行数:22,代码来源:rendering.py
示例18: draw_ring
def draw_ring(screen, rad, color, bg_color, xpos, ypos, thk, pct):
draw_filled_aacircle(screen, rad, color, xpos, ypos)
draw_filled_aacircle(screen, rad-thk, bg_color, xpos, ypos)
x_calc = xpos - 1.1*rad*np.cos(.5*np.pi + 2*np.pi*(1-pct))
y_calc = ypos - 1.1*rad*np.sin(.5*np.pi + 2*np.pi*(1-pct))
if pct > .75:
point_list = np.array([[xpos,ypos],
[x_calc,y_calc],
[xpos+1.5*rad,ypos-1.5*rad],
[xpos,ypos-1.5*rad],
[xpos,ypos]])
elif pct > .5:
point_list = np.array([[xpos,ypos],
[x_calc,y_calc],
[xpos+1.5*rad,ypos+1.5*rad],
[xpos+1.5*rad,ypos-1.5*rad],
[xpos,ypos-1.5*rad],
[xpos,ypos]])
elif pct > .25:
point_list = np.array([[xpos,ypos],
[x_calc,y_calc],
[xpos-1.5*rad,ypos+1.5*rad],
[xpos+1.5*rad,ypos+1.5*rad],
[xpos+1.5*rad,ypos-1.5*rad],
[xpos,ypos-1.5*rad],
[xpos,ypos]])
else:
point_list = np.array([[xpos,ypos],
[x_calc,y_calc],
[xpos-1.5*rad,ypos-1.5*rad],
[xpos-1.5*rad,ypos+1.5*rad],
[xpos+1.5*rad,ypos+1.5*rad],
[xpos+1.5*rad,ypos-1.5*rad],
[xpos,ypos-1.5*rad],
[xpos,ypos]])
polygon(screen, bg_color, point_list)
开发者ID:efunn,项目名称:hemo-control,代码行数:39,代码来源:game_graphics.py
示例19: createWarning
def createWarning(screen,message):
def close():
nonlocal tmpFrame
tmpFrame.kill()
# Creation
tmpFont = font.SysFont("Arial",34)
tmpText = tmpFont.render("!",1,(0,0,0))
tmpFrame = Frame(screen,htitle="Warning",width=300,height=100)
t = TypableSurface((160,90),text=message)
tmpSurface = Surface((42,36))
tmpButton = Button(tmpFrame,width=50,height=20,text="Ok",target=close)
# Assembly
tmpSurface.fill((255,255,255))
draw.polygon(tmpSurface,(255,255,0),[(20,0),(0,35),(40,35)])
draw.polygon(tmpSurface,(0,0,0),[(20,0),(0,35),(40,35)],3)
tmpSurface.blit(tmpText,(16,0))
tmpFrame.blit(tmpSurface,(2,10))
tmpFrame.blit(t,(50,10))
tmpButton.place((122,74))
tmpFrame.place((screen.get_width()//2-150,screen.get_height()//2-50))
return tmpFrame
开发者ID:annie60,项目名称:Xilarius,代码行数:24,代码来源:extension.py
示例20: draw_triangle
def draw_triangle (surface, color, a, b, c, width=0):
"""draw_triangle (...) -> Rect
Draws a triangle with the vertices a, b, c on a surface.
The 'color' argument needs to match the pygame color style. 'a',
'b', 'c' are sequences of the x- and y-coordinates of the three
vertices on th surface. 'width' denotes the width of lines in pixels
or, if set to 0, fills the triangle with the passed color. The
return value is the bounding box of the affected area.
The following example would draw a white, filled triangle on the
specified surface:
draw_triangle (surface, (255, 255, 255), (5, 1), (1, 5), (10, 5))
Note: This function is a wrapper around pygame.draw.polygon() with a
fixed three point list and thus all documentation about it can be
applied to this function, too.
"""
return draw.polygon (surface, color, [a, b, c], width)
开发者ID:BGCX067,项目名称:eyestabs-svn-to-git,代码行数:21,代码来源:Draw.py
注:本文中的pygame.draw.polygon函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论