当前位置: 首页>>代码示例>>Python>>正文


Python Circle.draw方法代码示例

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


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

示例1: MyGroup

# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import draw [as 别名]
class MyGroup(Group):
    """Represents a group on the floor.

    Create a group as a subclass of the basic data element.

    Stores the following values:
        m_color: color of cell

    """

    def __init__(self, field, id, gsize=None, duration=None, x=None, y=None,
                 diam=None, color=None):
        if color is None:
            self.m_color = DEF_GROUPCOLOR
        else:
            self.m_color = color
        self.m_shape = Circle()
        super(MyGroup, self).__init__(field, id, gsize, duration, x, y, diam)

    def update(self, gsize=None, duration=None, x=None, y=None,
                 diam=None, color=None):
        """Store basic info and create a DataElement object"""
        if color is not None:
            self.m_color = color
        super(MyGroup, self).update(gsize, duration, x, y, diam)

    def draw(self):
        if self.m_x is not None and self.m_y is not None:
            self.m_shape.update(self.m_field, (self.m_x, self.m_y),
                                self.m_diam/2, self.m_color, solid=False)
            self.m_shape.draw()
开发者ID:btownshend,项目名称:crs,代码行数:33,代码来源:mygroup.py

示例2: __init__

# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import draw [as 别名]
class Controller:
    def __init__(self):
        self.circle = Circle(width/2, height/2, 100)
    def draw(self):
        background(0, 0, 0)
	stroke(50, 50, 200) # set stroke color bluish
        self.circle.draw()
        self.circle.move(0.25,0.25)
开发者ID:charlesxian,项目名称:simulation_spring_2016_repo,代码行数:10,代码来源:example2-controller.py

示例3: __init__

# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import draw [as 别名]
class Controller:
    def __init__(self):
        self.circlea = Circle(PVector(width/2, height/2), 100, PVector(1, 1))
        self.circleb = Circle(PVector(width/2, height/2), 100, PVector(3, 3))
    
    def draw(self):
        background(0, 0, 0)
        self.circlea.draw()
        self.circleb.draw()
        self.circlea.move()
        self.circleb.move()
开发者ID:charlesxian,项目名称:simulation_spring_2016_repo,代码行数:13,代码来源:controller.py

示例4: __init__

# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import draw [as 别名]
class Controller:
    def __init__(self):                            # sx, sy
        self.circlea = Circle(width/2, height/2, 100, 1, 1)
        self.circleb = Circle(width/2, height/2, 100, 3, 3)
        
    def draw(self):
        background(0, 0, 0)
        self.circlea.draw()
        self.circleb.draw()
        self.circlea.move()
        self.circleb.move()
开发者ID:charlesxian,项目名称:simulation_spring_2016_repo,代码行数:13,代码来源:example3-controller.py

示例5: MyCell

# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import draw [as 别名]
class MyCell(Cell):
    """Represents one person/object on the floor.

    Create a cell as a subclass of the basic data element.

    Stores the following values:
        m_color: color of cell

    makeBasicShape: create the set of arcs that will define the shape

    """

    def __init__(self, field, id, x=None, y=None, vx=None, vy=None, major=None,
                 minor=None, gid=None, gsize=None, color=None):
        if color is None:
            self.m_color = DEF_LINECOLOR
        else:
            self.m_color = color
        self.m_body_color = DEF_BODYCOLOR
        self.m_shape = Circle()
        self.m_bodyshape = Circle()
        super(MyCell, self).__init__(field, id, x, y, vx, vy, major, minor,
                                     gid, gsize)

    def update(self, x=None, y=None, vx=None, vy=None, major=None,
               minor=None, gid=None, gsize=None, color=None, visible=None,
               frame=None):
        """Store basic info and create a DataElement object"""
        if color is not None:
            self.m_color = color
        super(MyCell, self).update(x, y, vx, vy, major, minor, gid, gsize,
                                   visible=visible, frame=frame)

    def draw(self):
        if self.m_x is not None and self.m_y is not None:
            self.m_shape.update(self.m_field, (self.m_x, self.m_y),
                                self.m_diam/2,
                                color=self.m_color,
                                solid=False)
            self.m_field.m_osc.send_laser(OSCPATH['graph_begin_cell'],[self.m_id])
            self.m_shape.draw()
            if DRAW_BODIES:
                self.m_bodyshape.update(self.m_field, (self.m_x, self.m_y),
                                          self.m_body_diam/2, 
                                          color=self.m_body_color,
                                          solid=True)
                self.m_bodyshape.draw()
            self.m_field.m_osc.send_laser(OSCPATH['graph_end_cell'],[self.m_id])
开发者ID:btownshend,项目名称:crs,代码行数:50,代码来源:mycell.py

示例6: __init__

# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import draw [as 别名]
class CircularPlayer:
    def __init__(self, initialPosition):
        self.playerCircle = Circle(initialPosition, 13, RED)
        self.speed = 5
        self.perspective = Box(initialPosition, float(WINDOWHEIGHT), float(WINDOWWIDTH), 0.0, (0, 255, 0))
    
    def updatePerspectiveByPosShift(self, xShift, yShift):
        self.perspective.updateByPosShift(xShift, yShift)
    
    def move(self, directionShift, listOfObjects):
        direction = self.perspective.rotation + directionShift
        centerBeforeMove = self.playerCircle.center
        self.playerCircle.move(direction, self.speed, listOfObjects)
        
        xShift = self.playerCircle.center[0] - centerBeforeMove[0]
        yShift = self.playerCircle.center[1] - centerBeforeMove[1]
        
        self.updatePerspectiveByPosShift(xShift, yShift)
        
    def rotate(self, rotation, listOfObjects):
        self.perspective.rotation = self.perspective.rotation + rotation
        
    def draw(self, surface, color):
        self.playerCircle.draw(surface, color)
    
    def getWhatToDraw(self, listOfObjects):
        circlesToDraw, boxesToDraw = [] , []
        whatToDraw = [circlesToDraw, boxesToDraw]

        for circle in listOfObjects[circles]:
            if self.perspective.doesBoxContainCircle(circle) == True:
                whatToDraw[circles].append(circle)
                
        for box in listOfObjects[boxes]:
            if self.perspective.doesBoxContainBox(box) == True:
                whatToDraw[boxes].append(box)
        whatToDraw[circles].append(self.playerCircle)
        return whatToDraw
    
    def drawMyView(self, surface, playingField, listOfObjects):
        whatToDraw = self.getWhatToDraw(listOfObjects)
        
        
        
        whatToDraw[boxes].insert(0, playingField)
        visualBoxes = []
        for i in range (0, len(whatToDraw[boxes])):
            visualBoxes.append(Box(whatToDraw[boxes][i].center, whatToDraw[boxes][i].width, whatToDraw[boxes][i].height, whatToDraw[boxes][i].rotation, whatToDraw[boxes][i].color))
            
            visualBoxes[i].center = (WINDOWWIDTH/2 + (visualBoxes[i].center[0] - self.perspective.center[0]), WINDOWHEIGHT/2 + (visualBoxes[i].center[1] - self.perspective.center[1]))
            visualBoxes[i].rotateAroundPoint(CENTEROFWINDOW, -math.pi/2 - self.perspective.rotation)
            
            visualBoxes[i].draw(surface)
            
            
        visualCircles = []
        for i in range (0, len(whatToDraw[circles])):
            visualCircles.append(Circle(whatToDraw[circles][i].center, whatToDraw[circles][i].radius, whatToDraw[circles][i].color))
            
            visualCircles[i].center = (WINDOWWIDTH/2 + (visualCircles[i].center[0] - self.perspective.center[0]), WINDOWHEIGHT/2 + (visualCircles[i].center[1] - self.perspective.center[1]))
            visualCircles[i].center = function.rotateAroundPoint(visualCircles[i].center, CENTEROFWINDOW, -math.pi/2 - self.perspective.rotation)
            
            visualCircles[i].draw(surface)
开发者ID:KoenP,项目名称:topdown,代码行数:65,代码来源:circularplayer.py


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