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


Python Graphics类代码示例

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


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

示例1: draw

 def draw(self):
     GraphicsCard.enable('blend')
     GraphicsCard.setBlendFunction('src_alpha', 'one_minus_src_alpha')
     GraphicsCard.disable('lighting', 'texture_2d')
     alpha = max( float(self.timeleft / 2.0), 0 )
     GraphicsCard.setColorRGBA( alpha/2.0, 0, 0, alpha )
     Graphics.drawSphere( self.location, 4, 8, 4 )
     GraphicsCard.enable('texture_2d')
开发者ID:fathat,项目名称:game-src,代码行数:8,代码来源:World.py

示例2: draw

	def draw(self):
		#find camera's transform matrix
		m = MathUtil.buildTransformMatrix(self.ent.headLocation,
										  self.ent.yaw + math.pi,
										  self.ent.pitch,
										  self.ent.roll)
		glPushMatrix()
		glMultMatrixf( m.toList() )
		Graphics.drawPyramid(30, 10, 100.0)
		Graphics.drawWirePyramid(30, 10, 100.0)
		glPopMatrix()
开发者ID:fathat,项目名称:game-src,代码行数:11,代码来源:AI.py

示例3: main

def main():
    # Loop until the user clicks the close button.
    done = False
    loopCount = 0
    while not done:
        loopCount += 1
        Input.update()
        if(Input.Trigger(Input.Close)):
            done = True
        map.update()
        Graphics.update()
开发者ID:BearXP,项目名称:Sumo2016_Pi,代码行数:11,代码来源:Game.py

示例4: SystemShutdown

 def SystemShutdown(self):
     import Graphics
     Graphics._ViewManager().Shutdown()
     self.exitTaskletManager = True
     # tell all services to shut down!
     for service in self._running_services.values():
         try:
             print "shutting down - ", service.__ID__
             service.state = SERVICE_STATES.STOPPED
             service.OnSystemShutdown()
         except Exception, e:
             print "Exception in Service", service.__ID__, e
开发者ID:robBabiak,项目名称:Portfolio,代码行数:12,代码来源:ServiceManager.py

示例5: runWin

def runWin():

	

	Label(window, image=photo).grid(row=0, column=1)

	Label(window, text="BigRep Configuration UI", font=Graphics.getBigRepFont(window, 40)).grid(row=0, column = 2)
开发者ID:jonasalexander,项目名称:configUI,代码行数:7,代码来源:Test.py

示例6: _processRenderSurface

def _processRenderSurface(logDir, attributes):
  def attr(name):
    return attributes[name]
    
  w, h            = attr("render_surface_width"), attr("render_surface_height")
  redMask         = attr("red_mask")
  greenMask       = attr("green_mask")
  blueMask        = attr("blue_mask")
  alphaMask       = attr("alpha_mask")
  depthMask       = attr("depth_mask")
  stencilMask     = attr("stencil_mask")
  isLinear        = attr("is_linear")
  isPremultiplied = attr("is_premultiplied")
  
  # Convert the color buffer
  if "color_buffer" in attributes:
    fileName    = attr("color_buffer")
    if not os.path.exists(fileName):
      fileName  = os.path.join(logDir, fileName)
    fileNameOut = fileName.rsplit(".", 1)[0] + ".png"
    
    # Only do the conversion if the image doesn't already exist
    # or if the source file is newer.
    if fileName.endswith(".dat") and \
       (not os.path.exists(fileNameOut) or \
        (os.path.exists(fileName) and os.path.getmtime(fileName) > os.path.getmtime(fileNameOut))
       ):
      stride      = attr("color_stride")
      
      f           = open(fileName, "rb")
      data        = f.read(stride * h)
      f.close()
      
      if len(data) != h * stride or not data:
        Log.error("Invalid color buffer data size: %d"  % len(data))
        return
      
      colorBuffer = Graphics.decodeImageData(data, (w, h), stride, redMask, greenMask, blueMask, alphaMask, isLinear, isPremultiplied)
      colorBuffer = colorBuffer.convert("RGBA")
      colorBuffer.save(fileNameOut)
      
      # We can remove the original file now
      os.unlink(fileName)
      
      # Replace the original file name with the decoded file
      attributes["color_buffer"] = fileNameOut
      
    # Eat the render surface attributes since they are of little use further down the road
    #for attrName in ["red_mask", "green_mask", "blue_mask", "alpha_mask",
    #                 "depth_mask", "stencil_mask", "color_stride",
    #                 "is_linear", "is_premultiplied", "color_data_type", 
    #                 "depth_data_type", "stencil_data_type"]:
    #  if attrName in attributes:
    #    del attributes[attrName]

  for bufferName in ["depth_buffer", "stencil_buffer"]:
    if bufferName in attributes and not os.path.exists(attributes[bufferName]):
      # Fill in the full buffer file name
      attributes[bufferName] = os.path.join(logDir, attr(bufferName))
开发者ID:se210,项目名称:tracy,代码行数:59,代码来源:Instrumentation.py

示例7: minConflicts

def minConflicts(csp, variables):
    """
    Min-conflicts approach to solving the Sudoku puzzle
    """
    
    assignment, domains = csp  # Domains not applicable for this problem, but included for readability
    
    # Iterate through list, and randomly assign numbers
    for var in variables:

        # Randomly assign number
        num = random.randint(1,9)
        
        # Update the stack to include the new number, whether it works or not
        assignment[var[0]][var[1]] = num
    
    
    # Loop while the problem is not solved
    while variables != []:
        
        Graphics.showPuzzle(assignment)
        
        print variables
        
        # Randomly choose a variable from the list
        var = random.choice(variables)
        
        # Create value for least-conflict value
        bestValue, leastConstraints = None, sys.maxsize
        
        # Loop over possible domain values, and update best value if applicable
        for value in range(1,10):
            conflicts = countConflicts(assignment, var, value)
            if conflicts < leastConstraints:
                bestValue, leastConstraints = value, conflicts
        
        # Update the state with the new value
        assignment[var[0]][var[1]] = bestValue
        
        # If the variable does not violate any constraints, remove it from conflicted
        if leastConstraints == 0:
            variables.remove(var) 
            
    print "Solution Found!"
    
    return assignment
开发者ID:uhsprogrammingclub,项目名称:sudoku-solver,代码行数:46,代码来源:Game.py

示例8: coefficients

def coefficients(model,labels,show=False,savename=None,title=None):

	fig = plt.figure(figsize=(8,10))
	ax = fig.add_subplot(111)
	x = -model.coef_.transpose()
	x /= np.absolute(x).max()
	y = np.arange(len(x))+0.5

	cutoff = scoreatpercentile(np.absolute(x),85)
	ax.barh(y,x,color=['r' if datum < 0 else 'g' for datum in x])
	ax.axvline(cutoff,linewidth=2,linestyle='--',color='r')
	ax.axvline(-cutoff,linewidth=2,linestyle='--',color='r')
	artist.adjust_spines(ax)
	ax.grid(True)
	ax.set_ylim(ymax=62)
	ax.set_xlim(xmin=-1.1,xmax=1.1)
	ax.set_yticks(y)
	ax.set_yticklabels(map(format,labels),y)
	ax.set_xlabel(format('Regression coefficient'))

	if title:
		ax.set_title(r'\Large \textbf{%s}'%title)
	plt.tight_layout()
	if show:
		plt.show()
开发者ID:mac389,项目名称:clinic,代码行数:25,代码来源:visualization.py

示例9: covariance

def covariance(heatmap,labels,show=False,savename=None,ml=False):
	#Covariance matrix
	fig = plt.figure(figsize=(13,13))
	ax = fig.add_subplot(111)
	cax = ax.imshow(heatmap,interpolation='nearest',aspect='equal')
	artist.adjust_spines(ax)
	ax.set_xticks(range(len(labels)))
	ax.set_xticklabels(map(artist.format,labels),range(len(labels)),rotation=90)

	ax.set_yticks(range(len(labels)))
	ax.set_yticklabels(map(artist.format,labels))

	if ml:
		ax.annotate(r'\LARGE \textbf{Training}', xy=(.2, .2),  xycoords='axes fraction',
		                horizontalalignment='center', verticalalignment='center')


		ax.annotate(r'\LARGE \textbf{Testing}', xy=(.7, .7),  xycoords='axes fraction',
		                horizontalalignment='center', verticalalignment='center')

	plt.colorbar(cax, fraction=0.10, shrink=0.8)
	plt.tight_layout()

	if savename:
		plt.savefig('%s.png'%savename,dpi=200)
	if show:
		plt.show()
开发者ID:mac389,项目名称:clinic,代码行数:27,代码来源:visualization.py

示例10: frequencies

	def frequencies(self,str, ax=None, cutoff=30):
		words = nltk.word_tokenize(''.join(ch for ch in str 
											if ch not in exclude 
												and ord(ch)<128 
												and not ch.isdigit()).lower())
		words = [word for word in words if word not in stopwords 
										and word not in emoticons 
										and word  not in ['rt','amp']]
		fdist = nltk.FreqDist(words)
		freqs = fdist.items()[:cutoff]
		word,f =zip(*freqs)
		f = np.array(f).astype(float)
		print f,'kkkkkkk'
		f /= float(f.sum())
		print f,'jjjjjjjjjjjj'
		if not ax:
			fig = plt.figure()
			ax = fig.add_subplot(111)

		ax.plot(-f*np.log(f),'k',linewidth=2)
		artist.adjust_spines(ax)
		ax.yaxis.grid()
		ax.xaxis.grid()
		ax.set_xticks(range(len(word)))
		ax.set_xticklabels(map(format,word),range(len(word)), rotation=45)
		ax.set_ylabel(r'\Large $\log \left(\mathbf{Frequency}\right)$')
		plt.tight_layout()
		plt.show()
开发者ID:emilyhpark,项目名称:Toxic,代码行数:28,代码来源:visualization.py

示例11: ecdf

def ecdf(data, show=False,savename=None):
	
 	ecdf = sm.distributions.ECDF(data)

 	x = np.linspace(data.min(),data.max())
 	y = ecdf(x)

 	cutoff = x[y>0.85][0]
	fig = plt.figure()
	ax = fig.add_subplot(111)
	ax.plot(x,y,'k',linewidth=3)
	artist.adjust_spines(ax)

	ax.annotate(r'\Large \textbf{Cutoff:} $%.03f$'%cutoff, xy=(.3, .2),  xycoords='axes fraction',
                horizontalalignment='center', verticalalignment='center')
	ax.set_xlabel(artist.format('Absolute Correlation'))
	ax.set_ylabel(artist.format('Percentile'))
	ax.axhline(y=0.85,color='r',linestyle='--',linewidth=2)
	ax.axvline(x=cutoff,color='r',linestyle='--',linewidth=2)
	ax.set_xlim((0,1))
	plt.tight_layout()

	if savename:
		plt.savefig('%s.png'%savename,dpi=200)
	if show:
		plt.show()

	return cutoff
开发者ID:mac389,项目名称:clinic,代码行数:28,代码来源:visualization.py

示例12: snapshots

def snapshots(data, indices,basepath=None, data_label='data'):
		indices = zip(indices,indices[1:])

		for start_idx,stop_idx in indices:
			initial_distribution = data[:,start_idx]
			final_distribution = data[:,stop_idx]

			fig = plt.figure()
			ax = fig.add_subplot(111)
			ax.hist(initial_distribution,color='r',alpha=0.5,bins=20,label='Initial', range=(-1,1))
			ax.hist(final_distribution,color='k',alpha=0.5,bins=20,label='Final',range=(-1,1))
			artist.adjust_spines(ax)
			ax.set_xlabel(artist.format(data_label))
			ax.set_ylabel(artist.format('Prevalence'))

			H,p =kruskal(initial_distribution,final_distribution)
			effect_size = np.linalg.norm(final_distribution-initial_distribution)
			ax.annotate('\Large $d=%.02f, \; p=%.04f$'%(effect_size,p), xy=(.3, .9),  
				xycoords='axes fraction', horizontalalignment='right', verticalalignment='top')
			plt.tight_layout()
			plt.legend(frameon=False)

			filename = os.path.join(basepath,'%s-compare-%d-%d.png'%(data_label,start_idx,stop_idx))
			plt.savefig(filename,dpi=300)	
			plt.close()
开发者ID:mac389,项目名称:at-risk-agents,代码行数:25,代码来源:visualization.py

示例13: plot

def plot(aList,ax, cutoff=20):
	tokens,frequencies = zip(*sorted(aList,key=lambda item:item[1],reverse=True))

	tokens = tokens[:cutoff][::-1]
	frequencies = frequencies[:cutoff][::-1]

	ax.plot(frequencies,xrange(cutoff),'k--', linewidth=2)
	artist.adjust_spines(ax)
	ax.set_yticks(xrange(cutoff))
	ax.set_yticklabels(map(artist.format,tokens),rotation='horizontal')
开发者ID:mac389,项目名称:phikal,代码行数:10,代码来源:analyze-descriptions.py

示例14: network_stability

def network_stability(energy_trace,savename):

	fig = plt.figure()
	ax = fig.add_subplot(111)
	ax.plot(energy_trace,'k',linewidth=2)
	artist.adjust_spines(ax)
	ax.set_xlabel(artist.format('Time'))
	ax.set_ylabel(artist.format('Stability (energy)'))

	plt.savefig('%s.png'%savename,dpi=200)
	plt.close()
开发者ID:mac389,项目名称:synchrony,代码行数:11,代码来源:visualization.py

示例15: plot_and_save

def plot_and_save(frequencies, words, ylabel, savefile):
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.semilogy(frequencies,'k--',linewidth=3)
    artist.adjust_spines(ax)

    ax.set_xticks(xrange(len(words)))
    ax.set_xticklabels([r'\textbf{\textsc{%s}'%word for word in words],rotation='vertical')
    ax.set_ylabel(artist.format(ylabel))

    plt.tight_layout()
    plt.show()
    plt.savefig(savefile, bbox_inches="tight")
开发者ID:mac389,项目名称:computational-medical-knowledge,代码行数:13,代码来源:plotSave.py


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