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


Python Graph.draw方法代码示例

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


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

示例1: drawWithGraph

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import draw [as 别名]
    def drawWithGraph(window, audioData):
        global p
        graph = Graph( Point(75, 50), 50)
        graph.draw(window)
        #p = None
        for d in audioData:
            if p:
                p.undraw()

            bx, by = normalize(d[0], d[1], d[2])

            p =  graph.createPoint(bx, by)
            p.draw(window)
开发者ID:TaitMadsen,项目名称:Vowel-Shapes,代码行数:15,代码来源:GraphicsModulePrototype_1_1.py

示例2: drawWithGraph

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import draw [as 别名]
    def drawWithGraph(self, audioData):
        # global p
        graph = Graph(Point(75, 50), 50)
        graph.draw(self.window)
        # p = None
        for d in audioData:
            if self.p:
                self.p.undraw()

            bx, by = self.normalize(d[0], d[1], d[2])

            # change the color if drawing the matching vowel point
            # then save it and return p to None
            if self.drawMatching:
                self.m = graph.createPoint(bx, by)
                self.m.setFill("green")
                self.m.setOutline("green")
                self.m.draw(self.window)
            else:
                self.p = graph.createPoint(bx, by)
                self.p.draw(self.window)
开发者ID:TaitMadsen,项目名称:Vowel-Shapes,代码行数:23,代码来源:GraphicsModule.py

示例3: __init__

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import draw [as 别名]
class GraphicsModule:

    def __init__(self, appWindow, viz="Graph", defVowel="i",
                    defFormants = [ [274.2, 2022.0, 3012.4] ], defTolerance = 0.1,
                    defQueueSize = 25, defGender = "Female"):
        #self.window = GraphWin('Vowel Shapes', width=w, height=h)
        self.window = appWindow

        # set the coordinates for the lower left and upper right corners
        #self.window.setCoords(0, 0, 100, 75)

        # initialize the visualization shapes to none so undraw works
        self.t = None
        self.o = None
        self.p = None
        self.m = None # the loaded draw viz if Practice mode
        self.mby = 0
        self.mbx = 0
        self.mArea = 0.0
        # try using a moving average of bx and by
        self.queueBx = []
        self.queueBy = []
        self.queueSize = defQueueSize
        self.vTolerance = defTolerance
        # set the default formant calculation - Female=1, Male=2
        self.gender = defGender

        # initializa the graph object and axis lines to none
        self.xA = None
        self.yA = None
        self.graph = None

        # setup the canvas
        #self.reDraw(viz)

        # set the boolean to determine the color of the viz based on
        # it being a loaded(matching) or active viz
        self.drawMatching = False
        # set the baseline vowel by character and baseline for practice mode
        #self.setVowelInfo(defVowel, defFormants)

    def drawMatchingViz(self, formant):
        self.drawMatching = True
        if self.m :
            self.m.undraw()
            self.mby = 0
            self.mbx = 0
            self.mArea = 0.0

        if self.useViz == "Graph" :
            bx, by = self.drawWithGraph(formant)
        elif self.useViz == "Oval" :
            bx, by = self.drawWithOval(formant)
            self.mArea = math.pi*(bx/2.0)*(by/2.0)
        elif self.useViz == "Triangle" :
            bx, by = self.drawWithTriangle(formant)
            self.mArea = (bx*by)/2.0
        self.mbx = bx
        self.mby = by
        self.drawMatching = False

    def drawWithOval(self, audioData):
        #o = None
        #global o
        for d in audioData:
            undrawo = False
            if self.o:
                #self.o.undraw()
                undrawo = True

            bx, by, delta = self.normalize(d[0], d[1], d[2])
            #o = createOval( Point(50, 37), 25, bx, by)
            if (self.drawMatching) :
                self.m = self.createOval( self.originViz, 25, bx, by, 10)
                self.m.draw(self.window)
            else :
                #self.o = self.createOval( self.originViz, 25, bx, by, delta)
                newO = self.createOval( self.originViz, 25, bx, by, delta)
                if (undrawo) :
                    self.o.undraw()
                self.o = newO
                self.o.draw(self.window)
            #print("Oval:", bx, by)
            return bx, by

            #print("f1: %s\nf2: %s\nf3: %s" % (d[0], d[1], d[2]) )
            #print("bx: %s\nby: %s\n" % (bx, by) )
            #time.sleep(1)

    def drawWithTriangle(self, audioData):
        #global t
        #t = None
        for d in audioData:
            undrawt = False
            if self.t :
                #self.t.undraw()
                undrawt = True

            bx, by, delta = self.normalize(d[0], d[1], d[2])
            #print("bx Triangle: ", self.queueBx)
#.........这里部分代码省略.........
开发者ID:TaitMadsen,项目名称:Vowel-Shapes,代码行数:103,代码来源:GraphicsModule.py


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