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


Python texture.Texture类代码示例

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


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

示例1: SimpleScreen

class SimpleScreen(Screen):
  """A screen with a single textured quad displaying a background image"""

  def __init__(self, ui, textureFile):
    super(SimpleScreen, self).__init__(ui)
    self._texture = Texture(textureFile)

  def draw(self):
    """Draw the menu background"""
    # Clear the screen
    glClearColor(0, 0, 0, 1)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

    glEnable(GL_TEXTURE_2D)

    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()

    self._texture.bind()
    glBegin(GL_QUADS)
    if True:
      glColor4f(1, 1, 1, 1)
      glTexCoord2f(0.0, 0.0); glVertex2f(-8.0, -6.0)
      glTexCoord2f(1.0, 0.0); glVertex2f( 8.0, -6.0)
      glTexCoord2f(1.0, 1.0); glVertex2f( 8.0,  6.0)
      glTexCoord2f(0.0, 1.0); glVertex2f(-8.0,  6.0)
    glEnd()
开发者ID:aarmea,项目名称:mumei,代码行数:27,代码来源:screen.py

示例2: test_resize

 def test_resize(self):
     data = np.zeros((10, 10), dtype=np.uint8)
     T = Texture(data=data)
     T.resize((5, 5))
     assert T.shape == (5, 5)
     assert T._data.shape == (5, 5)
     assert T._need_resize == True
     assert T._need_update == False
     assert len(T._pending_data) == 0
开发者ID:tatak,项目名称:experimental,代码行数:9,代码来源:test_texture.py

示例3: simple_patches_synthesizer

def simple_patches_synthesizer(args):
    print "Using Simple Patches Synthesizer"
    default_texture = Texture()
    default_texture.load_texture(args.input_file)
    patches = default_texture.create_patches(args.patch_height,
                                             args.patch_width)
    new_texture = Texture.create_simple_tex_from_patches(patches,
                                                         args.height,
                                                         args.width)   
    new_texture.save_texture(args.output_file)
    return
开发者ID:azgo14,项目名称:CS283,代码行数:11,代码来源:texture_synthesizer.py

示例4: __init__

class Menu_log:

#-------------------------------------------------------------------------------------------------------

	def __init__( self ):
		self.text = Text( "menu/KGHAPPY.ttf", 27, 255 )
		self.texture = Texture( "menu/exit.png", 255 )
		self.type = 0

#-------------------------------------------------------------------------------------------------------
	
	def load( self, width, height ):

		self.texture.setX( width/2 - self.texture.getWidth()/2 )
		self.texture.setY( height/2 - self.texture.getHeight()/2 )
		self.texture.setColor( 30, 0, 255 )

		self.text.createText( "m-menu  b-back", [ 0xFF, 0xFF, 0xFF ] )
		self.text.setX( width/2 - self.text.getWidth()/2 )
		self.text.setY( height/2 - self.text.getHeight()/2 )

#-------------------------------------------------------------------------------------------------------
	
	def draw( self, window ):
		if self.type == 1:
			self.texture.draw( window )
			self.text.draw( window )

#-------------------------------------------------------------------------------------------------------

	def getState( self ):
		return self.type

#-------------------------------------------------------------------------------------------------------

	def setState( self, t ):
		self.type = t

#-------------------------------------------------------------------------------------------------------

	def handle( self, event ):

		if event.type == pygame.KEYDOWN:

			if event.key == pygame.K_m:
				if self.type == 0:
					self.type = 1
				elif self.type == 1:
					self.type = 2

			elif event.key == pygame.K_b:
				if self.type == 1:
					self.type = 0
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:53,代码来源:menu_log.py

示例5: mincut_overlap_patches_synthesizer

def mincut_overlap_patches_synthesizer(args):
    print "Using Mincut Overlap Patches Synthesizer"
    default_texture = Texture()
    default_texture.load_texture(args.input_file)
    patches = default_texture.create_patches(args.patch_height,
                                             args.patch_width,
                                             overlap=args.overlap_percent)
    new_texture = Texture.create_mincut_tex_from_patches(patches,
                                                         args.height,
                                                         args.width)
    new_texture.save_texture(args.output_file)
    return 
开发者ID:azgo14,项目名称:CS283,代码行数:12,代码来源:texture_synthesizer.py

示例6: __init__

	def __init__(self, font_file):
		self._glyphs = {}
		self._kern = {}
		self._page = {}

		if "." not in font_file:
			font_file = font_file+".zip"

		with zipfile.ZipFile(font_file,'r') as z:
			if font_file.lower().endswith(".zip"):
				font_file = os.path.basename(font_file)[:-4]

			xml = z.read(font_file+".fnt")
			xroot = ET.fromstring(xml)
			# misc info
			com = xroot.find('common')
			self._line_height = int(com.get("lineHeight"))
			self._base = int(com.get("base"))
			self._imgw = int(com.get("scaleW"))
			self._imgh = int(com.get("scaleH"))
		

			# load the textures
			for page in xroot.find('pages').findall("page"):
				id = int(page.get("id"))
				img_filename = page.get("file")
				img = z.read(img_filename)
				surf = pygame.image.load(StringIO.StringIO(img),img_filename)
				tex = Texture()
				tex.setFromSurface(surf)
				self._page[id] = tex

				assert(id == 0) # for now, we only support single-page fonts
			
			# load the glyph data
			for char in xroot.find("chars").findall("char"):
				d = {}
				for f in self.Glyph._fields:
					d[f] = int(char.get(f))

				g=self.Glyph(**d)
				self._glyphs[g.id] = g

			# load the kerning data
			for kern in xroot.find("kernings").findall("kerning"):
				t = (int(kern.get("first")), int(kern.get("second")))
				self._kern[t] = int(kern.get("amount"))


		self._material = Material()

		self._material.setTexture(0,self._page[0])
开发者ID:Gato-X,项目名称:sPyGlass,代码行数:52,代码来源:text.py

示例7: PointCloud

class PointCloud(GLArray):
    def __init__(self, vertex_data=None, color_data=None):
        GLArray.__init__(self, vertex_data, color_data)
        self._sprite_texture = None

    def sprite(self, filename):
        print " -- initializing point sprite {}".format(filename)

        self._sprite_texture = Texture(filename)

    def _pre_draw(self):
        GLArray._pre_draw(self)

        if self._sprite_texture == None:
            return

        glDepthMask(GL_FALSE)

        glEnable(GL_POINT_SMOOTH)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE)

        self._sprite_texture.bind()

        glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)
        glEnable(GL_POINT_SPRITE)

        glPointSize(15.0)

    def _post_draw(self):
        GLArray._post_draw(self)

        if self._sprite_texture == None:
            return

        self._sprite_texture.unbind()

        glDisable(GL_BLEND)
        glDisable(GL_POINT_SPRITE)

    def center(self):
        try:
            return self._center
        except:
            self._center = [0.0, 0.0, 0.0]
            for i in range(3):
                self._center[i] = sum(v[i] for v in self._vertex_data) / len(self._vertex_data)
            return self._center
开发者ID:chebee7i,项目名称:vroom,代码行数:48,代码来源:point_cloud.py

示例8: __init__

	def __init__( self ):

		self.core = Core( 60, 1024, 768, "Ninja" )

		self.intro = Intro()

		self.menu_background = Texture( "menu/background.png" )
		self.menu_title = Menu_title()
		self.menu_play_button = Menu_play_button()
		self.menu_git_button = Menu_link_button( "menu/git.png", "https://github.com/Adriqun" )
		self.menu_google_button = Menu_link_button( "menu/google.png", "https://en.wikipedia.org/wiki/Ninja" )
		self.menu_facebook_button = Menu_link_button( "menu/facebook.png", "nothing", True )
		self.menu_twitter_button = Menu_link_button( "menu/twitter.png", "nothing", True )
		self.menu_music_button = Menu_music_button( "menu/music.png" )
		self.menu_chunk_button = Menu_music_button( "menu/chunk.png", 1 )
		self.menu_exit_log = Menu_exit_log()
		self.menu_author_log = Menu_author_log()
		self.menu_game_log = Menu_link_button( "menu/game.png", "nothing", True )
		self.menu_settings_log = Menu_link_button( "menu/settings.png", "nothing", True )
		self.menu_score_log = Menu_score_log()
		self.menu_music = Menu_music( "menu/Rayman Legends OST - Moving Ground.mp3" )
		
		self.wall = Wall()
		self.hero = Hero()
		self.menu_log = Menu_log()
		self.map = Map()
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:26,代码来源:engine.py

示例9: __init__

    def __init__(self, name, strategy, radius, latitudes, longitudes, rotation_speed, central_body, mass,
                 textureimage, longitude_of_the_ascending_node, argument_of_the_perihelion, inclination_to_ecliptic,
                 periapsis=0., apoapsis=0., angle=1.0):
        """
        Sets all the necessary attributes.
        """
        self.original_radius = radius
        self.name = name
        self.strategy = strategy
        self.position = BetterVector(periapsis, 0, 0)
        self.radius = radius
        self.latitudes = latitudes
        self.longitudes = longitudes
        self.rotation_speed = rotation_speed / 365 / 24 / 60 / 60
        self.central_body = central_body
        self.rotation = 0
        self.mass = mass
        self.textureimage = textureimage
        self.angle = angle
        self.periapsis = periapsis
        self.apoapsis = apoapsis
        self.texture = Texture(self.textureimage)
        self.sphere = gluNewQuadric()
        self.calc_speed()
        self.longitude_of_the_ascending_node = longitude_of_the_ascending_node
        self.argument_of_the_perihelion = argument_of_the_perihelion
        self.inclination_to_ecliptic = inclination_to_ecliptic
        self.is_real = False
        self.time = 0
        self.showTexture = True
        self.speed = 0

        gluQuadricNormals(self.sphere, GLU_SMOOTH)
        gluQuadricTexture(self.sphere, GL_TRUE)
开发者ID:sgeyer-tgm,项目名称:SolarSystem,代码行数:34,代码来源:models.py

示例10: __init__

	def __init__( self ):

		self.sprite = Sprite( "menu/position.png", 4 )
		self.window = Texture( "menu/window.png" )
		self.click = pygame.mixer.Sound( "menu/click.wav" )

		self.on = 0
		self.type = 0
		self.text = Text( "menu/KGHAPPY.ttf", 30 )
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:9,代码来源:menu_score_log.py

示例11: get

 def get(self, image):
     if isinstance(image, Texture):
         return image
     if image in self.cache:
         return self.cache[image]
     else:
         self.cache[image] =texture= Texture.empty(image.width, image.height)
         texture.upload(image.data)
         return texture
开发者ID:cheery,项目名称:essence,代码行数:9,代码来源:texturecache.py

示例12: __init__

	def __init__(self, map_lvl, canvas, x, y):
		super().__init__()
		self.map_level = map_lvl
		self.texture = Texture(canvas, x, y)
		self.img = self.skeleton_img
		self.canvas = canvas
		self.position = {'x': x, 'y': y}

		self.hp = 2 * self.map_level * self.dice()
		self.dp = self.map_level/2 * self.dice()
		self.sp = self.map_level * self.dice()
开发者ID:greenfox-velox,项目名称:szepnapot,代码行数:11,代码来源:skeleton.py

示例13: __init__

	def __init__( self, path, on = 0 ):

		self.sprite = Sprite( path, 4 )

		self.scratch = Texture( "menu/scratch.png" )
		self.click = pygame.mixer.Sound( "menu/click.wav" )

		self.type = 0
		self.state = 0
		self.on = on
		self.mouseup = 0
开发者ID:Adriqun,项目名称:C-CPP-SDL2,代码行数:11,代码来源:menu_music_button.py

示例14: Skeleton

class Skeleton(Character):

	def __init__(self, map_lvl, canvas, x, y):
		super().__init__()
		self.map_level = map_lvl
		self.texture = Texture(canvas, x, y)
		self.img = self.skeleton_img
		self.canvas = canvas
		self.position = {'x': x, 'y': y}

		self.hp = 2 * self.map_level * self.dice()
		self.dp = self.map_level/2 * self.dice()
		self.sp = self.map_level * self.dice()

	def draw(self):
		self.texture.draw_img(self.img)

	def __str__(self):
		return "(SKELETON) HP: {} | DP: {} | SP: {}".format(self.hp,
																							self.dp, self.sp)
开发者ID:greenfox-velox,项目名称:szepnapot,代码行数:20,代码来源:skeleton.py

示例15: draw_scanline

 def draw_scanline(self, va: Vertex, vb: Vertex, y: int, texture: Texture):
     x1 = int(va.position.x)
     x2 = int(vb.position.x)
     sign = 1 if x2 > x1 else -1
     factor = 0
     for x in range(x1, x2 + sign * 1, sign):
         if x1 != x2:
             factor = (x - x1) / (x2 - x1)
         # color = interpolate(v1.color, v2.color, factor)
         v = interpolate(va, vb, factor)
         color = texture.sample(v.u, v.v)
         self.draw_point(Vector(x, y), color)
开发者ID:happlebao,项目名称:rendererpy,代码行数:12,代码来源:canvas.py


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