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

Python image.load函数代码示例

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

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



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

示例1: __init__

    def __init__(self):
        self.image_opened = image.load(data_file('garbagecan-open.png'))
        self.image_closed = image.load(data_file('garbagecan-closed.png'))
        self.image_lid = image.load(data_file('garbagecan-lid.png'))

        self.image_opened.anchor_x = self.image_opened.width/2
        self.image_opened.anchor_y = self.image_opened.height/2
        self.image_closed.anchor_x = self.image_opened.width/2
        self.image_closed.anchor_y = self.image_opened.height/2

        self.candidateLeaves = {}

        self.opened = True
        self.lid_active = False
        self.can_active = False
        self.fallen = False
        self.can_highlighted = False
        self.lid_highlighted = True

        self.can_rect = Rect(0, 0, self.image_closed)
        self.can_rect.center = (80, 90)

        self.can_sprite = Sprite(self.image_opened)
        self.can_sprite.set_position(self.can_rect.x, self.can_rect.y)

        self.lid_rect = Rect(20, 40, self.image_lid)

        window.game_window.push_handlers(self.on_mouse_release)
        window.game_window.push_handlers(self.on_mouse_press)
        window.game_window.push_handlers(self.on_mouse_drag)
        window.game_window.push_handlers(self.on_mouse_motion)

        events.AddListener(self)
开发者ID:pdevine,项目名称:suburbia,代码行数:33,代码来源:garbage.py


示例2: __init__

    def __init__(self):
        super(GameLayer, self).__init__()

        # Lista de sprites (X's e O's)
        self.sprites = [None]*9

        # Intância do jogo
        self.game = None

        # Variavel para verificar se o usuário está habilitado à jogador. A 
        # variável estará falsa somente no caso de alguém ganhar ou o jogo 
        # empatar, esperando a finalização dos efeitos para habilitar o jogo 
        # novamente
        self.ableToPlay = True

        # Lista de imagens do jogo, elas são definidas separadamente para não
        # fiarem duplicadas em vários sprites.
        self.imageEmpty = image.load('resources/cell.png')
        self.imageX = image.load('resources/cell-x.png')
        self.imageO = image.load('resources/cell-o.png')
        
        # Imagem de fundo
        self.background = cocos.sprite.Sprite('background.png', (150, 150))
        self.add(self.background)

        # Inicia um novo jogo
        self.newGame()
开发者ID:jamgaroo1,项目名称:python-games,代码行数:27,代码来源:tictactoe.py


示例3: load_texture

    def load_texture(self):
        if self.texture_file:
            self.texture_file = join(dirname(__file__), self.texture_file)
            self.original_texture = image.load(self.texture_file).texture

            file = BytesIO()
            self.original_texture.save(self.texture_file, file,
                                       encoder=self.encoder)
            file.seek(0)
            self.saved_texture = image.load(self.texture_file, file).texture
开发者ID:bitcraft,项目名称:pyglet,代码行数:10,代码来源:base_save.py


示例4: __init__

    def __init__(self, x, y):

        spark_tex = image.load(os.path.join(os.path.dirname(__file__), 'images/flare3.png')).get_texture()

        sparks = ParticleGroup(
            controllers=[
                Lifetime(2),
                Movement(damping=0.93),
                Fader(fade_out_start=0, fade_out_end=1.8),
            ],

            renderer=BillboardRenderer(SpriteTexturizer(spark_tex.id)))

        spark_emitter = StaticEmitter(
            template=Particle(
                position=(x,y),
                color=(1,1,1)),
            deviation=Particle(
                position=(1,1,0),
                velocity=(300,300,0),
                age=1.5),
            size=[(1,1,0), (2,2,0), (2,2,0), (2,2,0), (3,3,0), (4,4,0)])
        spark_emitter.emit(50, sparks)

        fire_tex = image.load(os.path.join(os.path.dirname(__file__), 'images/puff.png')).get_texture()

        fire = ParticleGroup(
            controllers=[
            Lifetime(4),
            Movement(damping=0.95),
            Growth(10),
            Fader(fade_in_start=0, start_alpha=0, fade_in_end=0.5, max_alpha=0.4,
                fade_out_start=1.0, fade_out_end=1.0)
            ],
            renderer=BillboardRenderer(SpriteTexturizer(fire_tex.id)))

        fire_emitter = StaticEmitter(
            template=Particle(
                position=(x, y),
                size=(10,10,0)),
            deviation=Particle(
                position=(2,2,0),
                velocity=(70,70,0),
                size=(5,5,0),
                up=(0,0,pi*2),
                rotation=(0,0,pi*0.06),
                age=.3,),
            color=[(0.5,0,0), (0.5,0.5,0.5), (0.4,0.1,0.1), (0.85,0.3,0)],
        )
        fire_emitter.emit(200, fire)
开发者ID:phantomxc,项目名称:KrackedForc,代码行数:50,代码来源:explosion.py


示例5: test_set_icon_sizes

 def test_set_icon_sizes(self):
     self.width, self.height = 200, 200
     self.w = w = window.Window(self.width, self.height)
     w.set_icon(image.load(icon_file1),
                image.load(icon_file2),
                image.load(icon_file3),
                image.load(icon_file4),
                image.load(icon_file5))
     glClearColor(1, 1, 1, 1)
     while not w.has_exit:
         glClear(GL_COLOR_BUFFER_BIT)
         w.flip()
         w.dispatch_events()
     w.close()
开发者ID:LaneLutgen,项目名称:CSCI338-BinPacking,代码行数:14,代码来源:WINDOW_SET_ICON_SIZES.py


示例6: loadTexture

    def loadTexture( self ):
        textureSurface = image.load('data/multicolor512.png')
        self.text0 = textureSurface.get_mipmapped_texture()

        textureSurface = image.load('data/grass512.jpg')
        self.text1 = textureSurface.get_mipmapped_texture()

        textureSurface = image.load('data/sand512.png')
        self.text2 = textureSurface.get_mipmapped_texture()

        textureSurface = image.load('data/stone512.jpg')
        self.text3 = textureSurface.get_mipmapped_texture()

        textureSurface = image.load('data/water1024.jpg')
        self.sea_tex = textureSurface.get_mipmapped_texture()
开发者ID:Dejmas,项目名称:Terrain,代码行数:15,代码来源:terrain.py


示例7: load_textures

def load_textures():
	global texture
	textureSurface = image.load('star.bmp')
	texture=textureSurface.texture
	glBindTexture(GL_TEXTURE_2D, texture.id)
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR )
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR )
开发者ID:msarch,项目名称:py,代码行数:7,代码来源:NeHe+09-Stars+Animation.py


示例8: LoadTextures

 def LoadTextures(self):
   '''texture 0-5: faces, 6-11: hints, 12: blending screen, 13: char'''
   i = self.loading
   if i < len(self.textures): # for i in xrange(len(self.textures)):
     if i < len(self.ary_norm): imgfile = TEXIMG_FACE % i # bmp24 256x256
     elif i <= len(self.ary_norm) * 2: imgfile = TEXIMG_HINT
     else: imgfile = TEXIMG_CHAR[i - len(self.ary_norm) * 2 - 1]
     img = image.load(imgfile)
     self.textures[i] = img.get_texture()
     ix, iy = img.width, img.height
     rawimage = img.get_image_data()
     formatstr = 'RGBA'
     pitch = rawimage.width * len(formatstr)
     dat = rawimage.get_data(formatstr, pitch)
     self.dat[i] = (dat, ix, iy)
     if i > len(self.ary_norm): # skip face(0-5) and hint(6:white)
       j = i - len(self.ary_norm)
       d = []
       it = iter(dat)
       while it.__length_hint__():
         r, g, b, a = [ord(it.next()) for k in xrange(4)]
         if i < len(self.ary_norm) * 2 and r >= 128 and g >= 128 and b >= 128:
           r, g, b = r if j & 1 else 0, g if j & 2 else 0, b if j & 4 else 0
         elif i == len(self.ary_norm) * 2:
           r, g, b, a = [int(self.instbgc[k] * 255) for k in xrange(4)]
         else:
           r, g, b, a = r, g, b, 255 * (r + g + b) / (255 * 3)
         d.append('%c%c%c%c' % (r, g, b, a))
       dat = ''.join(d)
     glEnable(self.textures[i].target)
     glBindTexture(self.textures[i].target, self.textures[i].id)
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
     glTexImage2D(GL_TEXTURE_2D, 0, 3, ix, iy, 0,
       GL_RGBA, GL_UNSIGNED_BYTE, dat)
     self.loading = i + 1
开发者ID:idobatter,项目名称:HatsuneMiku,代码行数:35,代码来源:rcube.py


示例9: load_texture

def load_texture(file):
    raw = image.load(file)
    width, height = raw.width, raw.height
    texture = image.load(file).get_data('RGBA', width * 4) # 4bpp, RGBA format

    buffer = [0] # Buffer to hold the returned texture id
    glGenTextures(1, (GLuint * len(buffer))(*buffer))

    glBindTexture(GL_TEXTURE_2D, buffer[0])
    
    #Load textures with no filtering. Filtering generally makes the texture blur.
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture)
    
    return buffer[0]
开发者ID:Xyene,项目名称:Pycraft,代码行数:16,代码来源:texture.py


示例10: load

 def load(self):
     self._pyglet_image = image.load(self._filename)
     self._size_x = self._pyglet_image.width
     self._size_y = self._pyglet_image.height
     
     self._opengl_id = self._pyglet_image.get_texture().id
     self._loaded = True
开发者ID:freneticmonkey,项目名称:Epsilon,代码行数:7,代码来源:texture.py


示例11: __init__

 def __init__(self, pos, angle):
     super( Pellet, self ).__init__(image.load(os.path.normpath(r'../assets/Graphics/Pellet.png')))
     self.initialPosition = pos
     self.position = (pos)
     self.angle = angle
     self.time_alive = 0
     self.cshape = CircleShape(Vector2(self.get_rect().center[0], self.get_rect().center[1]), self.width/2)
开发者ID:WizardWizardSomething,项目名称:wizardwar,代码行数:7,代码来源:pellet.py


示例12: __init__

    def __init__(self):

        # A Batch is a collection of vertex lists for batched rendering.
        self.batch = pyglet.graphics.Batch()

        # A TextureGroup manages an OpenGL texture.
        self.group = TextureGroup(image.load(TEXTURE_PATH).get_texture())

        # A mapping from position to the texture of the block at that position.
        # This defines all the blocks that are currently in the world.
        self.world = {}

        # Same mapping as `world` but only contains blocks that are shown.
        self.shown = {}

        # Mapping from position to a pyglet `VertextList` for all shown blocks.
        self._shown = {}

        # Mapping from sector to a list of positions inside that sector.
        self.sectors = {}

        # Simple function queue implementation. The queue is populated with
        # _show_block() and _hide_block() calls
        self.queue = deque()

        self._initialize()
开发者ID:egeoz,项目名称:pycraft,代码行数:26,代码来源:fmain.py


示例13: __init__

 def __init__(self, filename):
     """Read data from the file"""
     self.contents = {}
     mtl = None
     for line in open(filename, "r"):
         if line.startswith('#'):
             continue
         values = line.split()
         if not values:
             continue
         if values[0] == 'newmtl':
             if len(values) == 1:
                 values.append('NoNameMat')
             mtl = self.contents[values[1]] = {}
         elif mtl is None:
             raise ValueError("mtl file doesn't start with newmtl stmt")
         elif values[0] == 'map_Kd':
             pos = filename.find('/') + 1
             mtl['map_Kd'] = filename[0:pos] + values[1]
             mtl['image'] = image.load(mtl['map_Kd'])
         elif values[0] == 'Ns':
             # Map from range 0-1000 to the range 0-128 of GL_SHININESS
             mtl['Ns'] = float(values[1]) * .128
         else:
             mtl[values[0]] = map(float, values[1:])
开发者ID:raycode,项目名称:pybilliard,代码行数:25,代码来源:obj.py


示例14: __init__

    def __init__(self):
        super( Ship, self ).__init__(image.load(os.path.normpath(r'../assets/Graphics/BookCraft.png')))

        self.drawModules()

        self.position = (250,250)
        self.heath = 100
        self.bulletList = []
        self.centerPoint = self.get_rect().center
        self.midline = (self.centerPoint, self.get_rect().midtop)
        self.cshape = CircleShape(Vector2(self.centerPoint[0],self.centerPoint[1]),self.width/2)

        # Constants for craft movement
        self.CRAFT_MAX_VELOCITY = 1000
        self.CRAFT_ACCELERATION = 100
        self.CRAFT_MAX_TURNRATE = 1

        # Keep track of the current move speed of the ship. These are accessed
        # directly by the scene controlling the ship
        self.craftMovingUp = False
        self.craftMovingDown = False
        self.craftMovingRight = False
        self.craftMovingLeft = False
        self.craft_x_velocity = 0
        self.craft_y_velocity = 0
开发者ID:WizardWizardSomething,项目名称:wizardwar,代码行数:25,代码来源:ship.py


示例15: __init__

    def __init__(self):
        super().__init__()

        self.scale = 0.8
        self.position = -50, -50

        explosion_animation = image.Animation.from_image_sequence(
            image.ImageGrid(image.load('explosion.png'), 1, 8), 0.1,
        )

        self.explosion = sprite.Sprite(
            explosion_animation,
            position=(320, 240),
            scale=1.5,
        )
        self.explosion2 = sprite.Sprite(
            explosion_animation,
            position=(160, 120),
            scale=1.7,
        )
        self.explosion3 = sprite.Sprite(
            explosion_animation,
            position=(32, 32),
        )
        self.add(self.explosion)
        self.explosion.add(self.explosion2)
        self.explosion2.add(self.explosion3)
开发者ID:fyabc,项目名称:MiniGames,代码行数:27,代码来源:try_sprite_box.py


示例16: __init__

    def __init__(
        self,
        radius=1,
        position=[0, 0, 0],
        velocity=[0, 0, 0],
        rotate=None,
        visible=False,
        slices=0,
        stacks=0,
        color=None,
        texture=None,
    ):
        self.radius = radius
        self.position = position
        self.velocity = velocity
        self.rotate = rotate

        self.visible = visible
        self.slices = slices
        self.stacks = stacks
        self.color = color
        self.texture = texture

        self.quadric = gluNewQuadric()

        if self.texture:
            self.image = image.load(self.texture)
            self.texture = self.image.get_texture()
            gluQuadricTexture(self.quadric, GL_TRUE)

            glEnable(self.texture.target)
            glBindTexture(self.texture.target, self.texture.id)

            glDisable(self.texture.target)
开发者ID:holocronweaver,项目名称:globe,代码行数:34,代码来源:globe.py


示例17: __init__

    def __init__(self):

        # A Batch is a collection of vertex lists for batched rendering.
        self.batch = pyglet.graphics.Batch()

        # A TextureGroup manages an OpenGL texture.
        self.group = TextureGroup(image.load(TEXTURE_PATH).get_texture())

        # A mapping from position to the texture of the block at that position.
        # This defines all the blocks that are currently in the world.
        self.world = {}

        # Same mapping as `world` but only contains blocks that are shown.
        self.shown = {}

        # Mapping from position to a pyglet `VertextList` for all shown blocks.
        self._shown = {}

        # Mapping from sector to a list of positions inside that sector.
        self.sectors = {}

        # Simple function queue implementation. The queue is populated with
        # _show_block() and _hide_block() calls
        self.queue = deque()
        #22222222222222
        try: 
            with open(WORLD_FILE, 'r') as f:
                json_representation = json.load(f)
                json_world = json_representation['world']
                for c in json_world:
                    self.add_block(tuple([int(d) for d in c.split(',')]), json_world[c], immediate=False)
        except IOError:
            self._initialize()
开发者ID:GerardoGR,项目名称:piecraft,代码行数:33,代码来源:main.py


示例18: init_textures

def init_textures(texture_file):
	"""Initializes textures."""
	global textures

	image = load(texture_file)
	texture_group = TextureGroup(image.get_texture())
	width_ratio = 1.0 / (float(image.width) / settings.texture_size)
	height_ratio = 1.0 / (float(image.height) / settings.texture_size)

	for name, coords in texture_mappings.texture_map.iteritems():
		master_x = coords[0] * width_ratio
		master_y = coords[1] * height_ratio
		x = coords[0] * settings.texture_size
		y = coords[1] * settings.texture_size

		#region = image.get_region(x, y, settings.texture_size, settings.texture_size).get_texture()

		# The vertices for the 2d texture, as percentages of the overall texture
		#textures[name]['coordinates'] = [x+width_ratio, y+height_ratio, x, y+height_ratio, x, y, x+width_ratio, y]
		textures[name] = {}
		textures[name]['coordinates'] = [1, 1, 0, 1, 0, 0, 1, 0]
		textures[name]['coordinates_for'] = lambda x, y: [x, y, 0, y, 0, 0, x, 0]
		textures[name]['master_coordinates'] = [master_x+width_ratio, master_y+height_ratio, master_x, master_y+height_ratio, master_x, master_y, master_x+width_ratio, master_y]
		#textures[name]['texture'] = region
		#textures[name]['group'] = TextureGroup(region)

	textures['master'] = {}
	textures['master']['group'] = texture_group
开发者ID:CIF-Rochester,项目名称:Basic-OpenGL-Seminar,代码行数:28,代码来源:texture.py


示例19: __init__

 def __init__(self, app, camera, showTime):
     self.__theApp = app
     self.__camera = camera
     splashImage = image.load( join('..','gfx','splash.png') )
     self.__texture = splashImage.texture
     self.__alpha = 0.0
     self.__showTime = showTime
开发者ID:mmilewski,项目名称:pyWorm,代码行数:7,代码来源:splash.py


示例20: __init__

    def __init__(self):
        self.images = [
            image.load(data_file('fire0.png')),
            image.load(data_file('fire2.png')),
            image.load(data_file('fire1.png')),
        ]

        self.image = self.images[0]
        pos = (randint(140, 350), randint(270, 400))
        self.rect = Rect(pos[0], pos[1], self.image)

        self.lives = 3

        self.delay = 0.2
        self.timer = self.delay
        self.image_count = 0
开发者ID:pdevine,项目名称:suburbia,代码行数:16,代码来源:grill.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python darwin._oscheck函数代码示例发布时间:2022-05-25
下一篇:
Python vertexbuffer.create_mappable_buffer函数代码示例发布时间: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