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


Python image.load函数代码示例

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


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


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