• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python draw.circle函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pygame.draw.circle函数的典型用法代码示例。如果您正苦于以下问题:Python circle函数的具体用法?Python circle怎么用?Python circle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了circle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: 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


示例2: tieFighter

def tieFighter (pos, screen, color, height=40):
    x, y = pos
    width = height/8
    draw.rect(screen, color, (x, y, width, height))
    draw.rect(screen, color, (x+height-width, y, width, height))
    draw.rect(screen, color, (x, y+(height-width)/2, height, width))
    draw.circle(screen, color, (x+height/2, y+height/2), height/4)
开发者ID:maedayx,项目名称:CS112-Spring2012,代码行数:7,代码来源:day8.py


示例3: draw_tie

def draw_tie(surf, color, pos, size=40):
    x, y = pos
    width = size/8
    draw.rect(surf, color, (x,y,width,size)) #first vertical line
    draw.rect(surf, color, (x+size-width,y,width,size)) #second vertical line
    draw.rect(surf, color, (x,y+(size-width)/2,size,width)) #middle horizontal
    draw.circle(surf, color, (x+size/2,y+size/2), size/4) #circle
开发者ID:BeefCakes,项目名称:CS112-Spring2012,代码行数:7,代码来源:Day8-3.py


示例4: drawGeom

def drawGeom(geom):
	if type(geom) is ode.GeomBox:
		x, y, _ = geom.getPosition()
		a, b, _ = geom.getLengths()
		r = geom.getRotation()
		costheta = r[0]; sintheta = r[1]
		p1 = to_screen_pnt(x + a/2 * costheta + b/2 * sintheta, y - a/2 * sintheta + b/2 * costheta)
		p2 = to_screen_pnt(x + a/2 * costheta - b/2 * sintheta, y - a/2 * sintheta - b/2 * costheta)
		p3 = to_screen_pnt(x - a/2 * costheta - b/2 * sintheta, y + a/2 * sintheta - b/2 * costheta)
		p4 = to_screen_pnt(x - a/2 * costheta + b/2 * sintheta, y + a/2 * sintheta + b/2 * costheta)
		draw.lines(screen, actual_color(getattr(geom, 'color', blue)), True, [p1, p2, p3, p4])
	elif type(geom) is ode.GeomSphere:
		x, y, _ = geom.getPosition()
		r = geom.getRadius()
		rotmat = geom.getRotation()
		costheta = rotmat[0]; sintheta = rotmat[1]
		px, py = to_screen_pnt(x, y)
		pr = to_screen_len(r)
		draw.circle(screen, actual_color(getattr(geom, 'color', blue)), (int(px), int(py)), int(pr), 1)
		drawLine((x,y), (x + costheta * r, y - sintheta * r), getattr(geom, 'color', blue))
	elif type(geom) is ode.GeomCapsule:
		x, y, _ = geom.getPosition()
		pass
	elif isinstance(geom, ode.SpaceBase):
		for i in geom:
			drawGeom(i)
	else:
		assert False
开发者ID:matthew-nichols,项目名称:waterbug,代码行数:28,代码来源:render.py


示例5: draw_tie

def draw_tie(surf, pos, color=RED):
    "draw a tie fighter at location"
    x,y = pos
    draw.rect(surf, color, (x, y, 5, 40))
    draw.rect(surf, color, (x+35, y, 5, 40))
    draw.rect(surf, color, (x, y+17, 40, 5))
    draw.circle(surf, color, (x+20, y+20), 10)
开发者ID:HampshireCS,项目名称:cs143-Spring2012,代码行数:7,代码来源:tiefighter4.py


示例6: main

def main():
    rect = Rect((0, 0), SCREEN_SIZE)
    surface = Surface(SCREEN_SIZE)
    pxarray = PixelArray(surface)
    P = [(0, 100), (100, 0), (200, 0), (300, 100), (400, 200), (500, 200),
         (600, 100), (400, 400), (700, 50), (800, 200)]
    n = len(P) - 1 # n = len(P) - 1; (P[0], ... P[n])
    k = 3          # degree of curve
    m = n + k + 1  # property of b-splines: m = n + k + 1
    _t = 1 / (m - k * 2) # t between clamped ends will be evenly spaced
    # clamp ends and get the t between them
    t = k * [0] + [t_ * _t for t_ in xrange(m - (k * 2) + 1)] + [1] * k

    S = Bspline(P, t, k)
    # insert a knot (just to demonstrate the algorithm is working)
    S.insert(0.9)

    step_size = 1 / STEP_N
    for i in xrange(STEP_N):
        t_ = i * step_size
        try: x, y = S(t_)
        # if curve not defined here (t_ is out of domain): skip
        except AssertionError: continue
        x, y = int(x), int(y)
        pxarray[x][y] = (255, 0, 0)
    del pxarray

    for p in zip(S.X, S.Y): draw.circle(surface, (0, 255, 0), p, 3, 0)
    SCREEN.blit(surface, (0, 0))

    while 1:
        for ev in event.get():
            if ev.type == KEYDOWN:
                if ev.key == K_q: exit()
        display.update()
开发者ID:homata,项目名称:pycurve,代码行数:35,代码来源:bspline.py


示例7: draw_points

def draw_points(poly, surface, color=None, width=None):
    polygon = orient_multipoint(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

    maxd = (0,None,None)
    for i in range(len(polygon.geoms)):
        p = polygon.geoms[i]
        draw.circle(surface, color,
                    defloat(scale(offset((p.x,p.y), dx, dy))),
                    3*width)
        for j in range(i+1, len(polygon.geoms)):
            q = polygon.geoms[j]
            d = p.distance(q)
            if d > maxd[0]:
                maxd = (d, p, q)
    if maxd[0] > 0:
        p, q = maxd[1], maxd[2]
        draw.line(surface, color,
                  defloat(scale(offset((p.x,p.y), dx, dy))),
                  defloat(scale(offset((q.x,q.y), dx, dy))), width)
开发者ID:tps12,项目名称:Why-So-Spherious,代码行数:27,代码来源:Collide.py


示例8: draw

 def draw(self, surface, offset):
     adjusted_center = (int(self.center[0] + offset[0]), int(self.center[1] + offset[1]))
     real_colour = [self.colour[i] + self.colour_change[i] * self.age for i in range(3)]
     
     # Typecast to an int to stop float warning
     radius = int(self.radius + self.radius_change * self.age)
     draw.circle(surface, bound_colour(real_colour), adjusted_center, radius, min(2, radius))
开发者ID:Teifion,项目名称:Sequtus-2,代码行数:7,代码来源:effects.py


示例9: test_filled_circles

def test_filled_circles(test_surf):
    """Draw several filled circles"""
    for cent_x, color in ((100, (0, 0, 255, 255)), (400, (0, 255, 255, 255)), (600, (255, 0, 255, 255))):
        cent_y = 10
        for radius in range(10, 100, 10):
            cent_y += radius + 1
            draw.circle(test_surf, color, (cent_x, cent_y), radius)
开发者ID:CTPUG,项目名称:pygame_cffi,代码行数:7,代码来源:test_shapes.py


示例10: draw_tie

def draw_tie(surf, color, pos, size=40):
    x, y = pos
    width = size/8
    draw.rect(surf, color, (x,y,width,size))
    draw.rect(surf, color, (x+size-width,y,width,size))
    draw.rect(surf, color, (x,y+(size-width*5),size,width))
    draw.circle(surf, color, (x+size/2,y+size/2),size/4)
开发者ID:bitpit,项目名称:CS112-Spring2012,代码行数:7,代码来源:day8.py


示例11: run

    def run(self):
        radius = 70
        (xoff, yoff) = (self.dim[0] / 2, self.dim[1] / 2)
        (xscale, yscale) = (1, 0.5)
        while True:
            if self.iter > 2 * math.pi:
                self.iter = 0
            self.iter += 0.01

            (x1, y1) = (math.cos(self.iter) * xscale, math.sin(self.iter) * yscale)
            (x2, y2) = (math.cos(self.iter + math.pi / 2) * xscale, math.sin(self.iter + math.pi / 2) * yscale)
            (x3, y3) = (int(-x1 * radius + xoff), int(-y1 * radius + yoff))
            (x4, y4) = (int(-x2 * radius + xoff), int(-y2 * radius + yoff))
            (x1, y1) = (int(x1 * radius + xoff), int(y1 * radius + yoff))
            (x2, y2) = (int(x2 * radius + xoff), int(y2 * radius + yoff))

            # self.lock.acquire()
            self.surface.fill(black)

            draw.lines(self.surface, green, True, [(x1, y1), (x2, y2), (x3, y3), (x4, y4)], 3)
            draw.lines(self.surface, green, True, [(x1, y1 - radius), (x2, y2 - radius), (x3, y3 - radius), (x4, y4 - radius)], 3)
            draw.line(self.surface, green, (x1, y1), (x1, y1 - radius), 3)
            draw.line(self.surface, green, (x2, y2), (x2, y2 - radius), 3)
            draw.line(self.surface, green, (x3, y3), (x3, y3 - radius), 3)
            draw.line(self.surface, green, (x4, y4), (x4, y4 - radius), 3)

            vdot = rotate_vector((0, 0.6), self.iter)
            draw.circle(self.surface, green, (int(vdot[0] * radius * xscale + xoff), int(vdot[1] * radius * yscale + yoff - radius)), 5)

            # self.clock.lock.acquire()
            self.surface.blit(self.clock.surface, (self.dim[0] - self.clock.get_dimensions()[0] - 10, 0))
            # self.clock.lock.release()

            # self.lock.release()
            time.sleep(0.005)
开发者ID:farhaven,项目名称:wallhack_display,代码行数:35,代码来源:subraum.py


示例12: _show_detection

 def _show_detection(self):
     if hasattr(self.status, 'detected_by'):
         radius = 0
         for obj in self.status.detected_by:
             if obj.selected:
                 radius += 6
                 pos = (self.rect.width // 2, self.rect.height // 2)
                 circle(self.image, obj._debug_color, pos, radius, 3)
开发者ID:suguby,项目名称:robogame_engine,代码行数:8,代码来源:user_interface.py


示例13: drawTie

def drawTie(surf, color, pos, size=80):
    x, y = pos
    width = size / 8
    # Drawing Tie Fighter here
    draw.rect(surf, color, (x, y, width, size))
    draw.rect(surf, color, (x + size - width, y, width, size))
    draw.rect(surf, color, (x, y + (size - width) / 2, size, width))
    draw.circle(surf, color, (x + size / 2, y + size / 2), size / 4)
开发者ID:sgoodspeed,项目名称:CS112-Spring2012,代码行数:8,代码来源:tieFighter.py


示例14: test_hollow_circles

def test_hollow_circles(test_surf):
    """Draw several circles of different thicknesses and sizes"""
    for thickness in range(1, 7):
        cent_x = 100 + thickness * 50
        cent_y = 10
        for radius in range(10, 200, 10):
            cent_y += radius + 1
            draw.circle(test_surf, (255, 255, 255, 255), (cent_x, cent_y), radius, thickness)
开发者ID:CTPUG,项目名称:pygame_cffi,代码行数:8,代码来源:test_shapes.py


示例15: red_bike

def red_bike(surf, pos, color=(255, 0, 0), size=40):
    x, y = pos

    width = size / 8

    draw.circle(surf, color, (x, y, width, size))
    draw.rect(surf, color, (x + (size - width), y, width, size))
    draw.circle(surf, color, (x + size / 2, y + size / 2), size / 4)
开发者ID:nigelgant,项目名称:CS112-Spring2012,代码行数:8,代码来源:tron.py


示例16: display

	def display(self, surface):

		myfont = font.Font(None, 2*self.display_weight)
		label = myfont.render(self.label, 1, Config.vertex_label_color)

		d_pos = ( int(self.x) + (Config.frameWidth/2), int(self.y) + (Config.frameHeight/2) )
		circle(surface, self.color, d_pos, self.display_weight, self.width)

		surface.blit(label, (d_pos[0]+self.display_weight+5,d_pos[1]))
开发者ID:PanosRCng,项目名称:1kg_code,代码行数:9,代码来源:graph.py


示例17: head

def head(surface, mod, pos):
    # adjust for body size
    radius = ((mod["bodySize"] + 1) * 4) + 10

    color = skinColor(mod)

    draw.circle(surface, (0,0,0), pos, radius)
    draw.circle(surface, color, pos, int(radius * .90))
    return Rect(pos[0] - radius, pos[1] - radius, radius * 2, radius * 2)
开发者ID:MacLeek,项目名称:mh,代码行数:9,代码来源:mob.py


示例18: draw_chess

def draw_chess(screen, gobang):
    board = gobang.board
    cols, rows = board.shape
    chess_radius = grid_size / 2 - 2
    for c in xrange(cols):
        for r in xrange(rows):
            v = board[(c,r)]
            if v in chess_colors:
                draw.circle(screen, chess_colors[v], to_pixel_pos((c, r)), chess_radius)
开发者ID:chqiwang,项目名称:gobang,代码行数:9,代码来源:inter.py


示例19: drawTieFighter

def drawTieFighter(surf, pos, size = 40, col=(100,100,100)):
    width = size / 8

    x,y = pos
    
    draw.rect(screen, col, (x+0, y+0, width, size))
    draw.rect(screen, col, (x+size - width, y, width, size))
    draw.rect(screen, col, (x, y + (size - width)/2, size,width))
    draw.circle(screen, col, (x + size/2, y+ size / 2), size/4)
开发者ID:habahut,项目名称:CS112-Spring2012,代码行数:9,代码来源:taiFighter.py


示例20: draw

 def draw(self):
     # light = self._LIGHT
     # for px, py, r in self.trail[::-1]:
     #     pygame.draw.circle(self.surface,
     #                        (light,0,0),
     #                        list(map(Utils.round_int,[px,py])),
     #                        r)
     #     light += self._LIGHT
     draw.circle(self.surface, self._COLOR, list(map(Utils.round_int, self.pos)), self.radius)
开发者ID:kimthuy,项目名称:pingpong,代码行数:9,代码来源:ball.py



注:本文中的pygame.draw.circle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python draw.line函数代码示例发布时间:2022-05-25
下一篇:
Python display.update函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap