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


Python image.Image类代码示例

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


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

示例1: load_walls

def load_walls(state, base_name, background_file, tile_file, with_collisions=True):
        """
        TODO
        """
        tile_size = screen.get_tile_size(state)
        int_tile_size = int(tile_size)
        background_texture = Image(source=background_file).texture
        walls_texture = Image(source=tile_file).texture
        for tile_name, origin_xy, collision in tiles_origin_table:
                full_tile_name = base_name + tile_name
                wall_texture = walls_texture.get_region(
                        origin_xy[0] * int_tile_size,
                        origin_xy[1] * int_tile_size,
                        int_tile_size,
                        int_tile_size)

                tile_texture = Texture.create(size=(int_tile_size, int_tile_size), colorfmt='rgba')
                fbo = Fbo(size=(int_tile_size, int_tile_size), texture=tile_texture)
                with fbo:
                        Color(1, 1, 1)
                        Rectangle(pos=(0, 0), size=tile_texture.size, texture=background_texture)
                        Rectangle(pos=(0, 0), size=tile_texture.size, texture=wall_texture)
                fbo.draw()
                if not with_collisions:
                        collision = None
                tiles.add_tile_def(state, full_tile_name, tile_texture, collision)
开发者ID:rkibria,项目名称:yapyg,代码行数:26,代码来源:tiles_helpers.py

示例2: on_touch_down

	def on_touch_down(self, touch):
		userdata = touch.ud
		(w, h) = (FSW,FSH)
		sc = max(float(w)/FSW,float(h)/FSH)
		# start collecting points in touch.ud
		self.canvas.clear
		gimg = Image(source=GOAL_IMG)
		self.add_widget(gimg)
		bimg = Image(source=BALL_IMG)
		self.add_widget(bimg)
		(xpos, ypos) = (int(touch.x)-w/2, int(touch.y)-h/2)
		#bimg.size = (10,10) #(int(60.0*sc), int(60.0*sc))
		bimg.pos = (xpos, ypos)
		#print '{0} and {1}'.format(float(w)/FSW,float(h)/FSH) 2115
		#print sc
		print '{0} and {1}'.format(touch.x, touch.y)
		#print '{0} and {1}'.format(xpos, ypos)
		if touch.x > FSW/20 and touch.x < w-FSW/20 and touch.y > h*0.2 and touch.y < h*0.88:
			print "GOAL!"
			mimg = Image(source=MSG_IMG)
			self.add_widget(mimg)
		#with self.canvas:
			#Color(1, 1, 1)
			#d = 60.
			#Ellipse(pos=(touch.x - d/2, touch.y - d/2), size=(d, d))
		return True
开发者ID:Sebelino,项目名称:Team18,代码行数:26,代码来源:FB.py

示例3: _detect_qrcode_frame

        def _detect_qrcode_frame(self, instance, camera, data):
            global data_qr
            # the image we got by default from a camera is using the NV21 format
            # zbar only allow Y800/GREY image, so we first need to convert,
            # then start the detection on the image
            parameters = camera.getParameters()
            size = parameters.getPreviewSize()
            barcode = Image(size.width, size.height, 'NV21')
            barcode.setData(data)
            barcode = barcode.convert('Y800')

            result = self._scanner.scanImage(barcode)

            if result == 0:
                self.symbols = []
                return

            # we detected qrcode! extract and dispatch them
            symbols = []
            it = barcode.getSymbols().iterator()
            while it.hasNext():
                symbol = it.next()
                qrcode = BtmsValidRoot.Qrcode(
                    type=symbol.getType(),
                    data=symbol.getData(),
                    quality=symbol.getQuality(),
                    count=symbol.getCount(),
                    bounds=symbol.getBounds())
                symbols.append(qrcode)

                data_qr = symbol.getData()
                #self.ids.result_label.text = data_qr
                self.validate()
            self.symbols = symbols
开发者ID:jaques30081983,项目名称:btms_suite,代码行数:34,代码来源:main.py

示例4: __init__

    def __init__(self, previous, image_set, fragment_list=None, **kwargs):
        super(GameScreen, self).__init__(**kwargs)
        # screen we came from, to pass on to game over/victory screen
        self.previous = previous

        # set image for the map and prepare it for color selection
        self.source = image_set.sources["raw"]
        self.image.imdata = utils.ImageArray.load(self.source)
        self.image.bind(on_touch_down=self.color_drop)

        # loads fragments from fragment directory
        self.f_index = 0
        self.fragments = []
        if os.path.exists(config.fragment_directory):
            for f in os.listdir(config.fragment_directory):
                if fragment_list is None or f in fragment_list:
                    imgpath = os.path.join(config.fragment_directory, f)
                    if os.path.isfile(imgpath):
                        img = Image(source=imgpath)
                        img.bind(on_touch_down=self.im_press)
                        self.fragments.append(img)

        # cursor options
        self.cursor_active = False
        self.cursor_array = self.fragments

        self.picker = None
        self.scatter = None
        self.cutter_event = None

        # starting values
        self.completion = 0
        self.tree_start = self.tree.height
        self.forest_color = None
        self.started = False
开发者ID:paranoodle,项目名称:ForestDefenders2,代码行数:35,代码来源:main.py

示例5: build

 def build(self):
     label = Label(text="Testing going on.")
     atlas = Atlas("player_sheet.atlas")
     image1 = Image(allow_stretch=True)
     image1.texture = atlas["walkleft4"]
     label.add_widget(image1)
     return label
开发者ID:Exodus111,项目名称:Projects,代码行数:7,代码来源:test.py

示例6: addImage

    def addImage(self, filename):
	image = Image(source=filename)
	image.size_hint = None, None
	image.width = metrics.sp(120)
	image.height = metrics.sp(120)
	self.add_widget(image)
	return
开发者ID:ik486,项目名称:kivy_examples,代码行数:7,代码来源:a16_images_fixedsize.py

示例7: __load_map_scene

    def __load_map_scene(self, map_name):
        scene_path = os.path.join('resources', 'maps', map_name, 'scene.json')
        scene_dict = json.load(open(scene_path))

        scene_width = 1080
        scene_height = 800
        layer_list = scene_dict['layers']
        first_layer_dict = layer_list[0]
        pivot_pos = (first_layer_dict['x'], first_layer_dict['y'])
        for layer_dict in reversed(layer_list[1:]):
            layer_pos = (layer_dict['x'] - pivot_pos[0], layer_dict['y'] - pivot_pos[1])
            layer_size = (layer_dict['w'], layer_dict['h'])
            layer_name = layer_dict['name'] 
            layer_path = os.path.join('resources', 'maps', map_name, 'images', layer_name + '.png')
            
            layer_color = [random(), random(), random(), 1]
            layer_image = Image(source=layer_path, pos=layer_pos, size=layer_size, pos_hint={}, size_hint=(None, None), color=layer_color)
	    with layer_image.canvas.before:
		layer_image.bg_rect = Line(rectangle=(layer_pos[0], layer_pos[1], layer_size[0], layer_size[1]))
            self.add_widget(layer_image)
            
            layer_label = Label(text="[color=000000]"+layer_name+"[/color]", pos=layer_pos, size=layer_size, pos_hint={}, size_hint=(None, None), markup=True)
            self.add_widget(layer_label)

	layer_label = Label(text="[color=000000]!!!![/color]", pos=(0, 0), pos_hint={}, size_hint=(None, None), markup=True)
	self.add_widget(layer_label)
开发者ID:pystrategy,项目名称:vegabonds,代码行数:26,代码来源:main.py

示例8: cancel

 def cancel(self):
     self.root.ids.display.clear_widgets()
     if not (self.slic == None):
         img = Image(source=self.slic.filename)
         img.id = 'disp_img'
         self.root.ids.display.add_widget(img)
         self.img_loaded = True
开发者ID:hagisgit,项目名称:SLIC,代码行数:7,代码来源:main.py

示例9: _draw_hearts

 def _draw_hearts(self):
     self.clear_widgets()
     i = 0
     while i < (self.max_health / 4):
         heart = Image(size=(80, 80))
         heart.source = 'img/heart-' + str(self.hearts[i]) + '.png'
         self.add_widget(heart)
         i += 1
开发者ID:victor-rene,项目名称:kivy-gamelib,代码行数:8,代码来源:heartbar.py

示例10: load

 def load(self, path, selection):
     if not selection[0] == '':
         self.slic = Slic(selection[0])
         self.root.ids.display.clear_widgets()
         img = Image(source=selection[0])
         img.id = 'disp_img'
         self.root.ids.display.add_widget(img)
         self.img_loaded = True
开发者ID:hagisgit,项目名称:SLIC,代码行数:8,代码来源:main.py

示例11: __init__

	def __init__(self, *args, **kwargs):
		super(Goal, self).__init__(*args, **kwargs)
		print "__init__ is run"
		gimg = Image(source=GOAL_IMG)
		self.add_widget(gimg)
		gimg.pos = (0,0)
		#Window.fullscreen = True
		Window.size = (FSW, FSH)
开发者ID:Sebelino,项目名称:Team18,代码行数:8,代码来源:Football.py

示例12: __init__

 def __init__(self, sheet, **kwargs):
     Image.__init__(self, **kwargs)
     self.sheet = sheet
     self._frame = None
     self.frame = 0
     self.dt = None
     self.loop_fnc = None
     self.register_event_type("on_finish")
开发者ID:2xR,项目名称:legacy,代码行数:8,代码来源:_sprite.py

示例13: handleGoal

    def handleGoal(self):
        def go_next_callback(instance):
            self.popup.dismiss()
            main.switchLevel()
            return False
            
        if self.isToolOnGoal and self.isPersonOnGoal:
            if self.activeTool.isGoal and self.activePerson.isGoal:
                print "FINISHED? ",isFinished
                while not isFinished: #notwendig, weil sonst 2 mal aufgerufen (touch_events feuern alle 2 mal)
                    global isFinished
                    isFinished = True
                    
                    btnBGSource = ''
                         
                    if currentLevel <= len(levels)-1:
                        btnBGSource = unichr(61518)
                    else:
                        btnBGSource = unichr(61470)
                                           
                    box = AnchorLayout(size_hint=(1, 1), anchor_x= "right", anchor_y= "bottom")     
                    btn = Button(font_size=100, font_name= 'res/fontawesome-webfont.ttf', text=btnBGSource, background_color = [0,0,0,0.7])
                    btn.bind(on_press=go_next_callback)
                    
                    #vid = Video(source=self.levelInfos[levelProps[3]], play=True)                    
                    #box.add_widget(vid)
                    
                    #instead of laggy video insert just an image
                    img = Image(source=self.levelInfos[levelProps[3]])
                    img.allow_stretch = True
                    box.add_widget(img)
                    imgBtn = Button(font_size=60, font_name= 'res/fontawesome-webfont.ttf', text=btnBGSource, background_color = [0,0,0,0], size_hint= (0.15, 0.15))
                    imgBtn.bind(on_press=go_next_callback)
                    box.add_widget(imgBtn)
                    
                    def end_of_vid(video, eos):
                        logging.info("endofvid")
                        #video.play=False #not working on android...
                        box.add_widget(btn)
                        #video.unload() #not working on android...
                        #logging.info("video unloaded")
                        
                    def showit():
                        print "showing video popup"
                        self.popup.open()
                        if self.winSound:
                            self.winSound.play()

                    #vid.bind(loaded=lambda foo,bar: showit())
                    #vid.bind(eos=lambda video,eos:end_of_vid(video,eos))
                                                                          
                         
                    self.popup = Popup(content=box,size_hint=(0.8, 0.7),auto_dismiss=False)
                    
                    self.hidePopupTitle(self.popup)
                    
                    showit()
                    Clock.schedule_once(lambda wumpe:box.add_widget(btn), 8)
开发者ID:HSA-IMS-Kivy-2,项目名称:Master_Emergency_Situations,代码行数:58,代码来源:main.py

示例14: __init__

    def __init__(self, idx, name, **kwarg):
        Image.__init__(self, **kwarg)
        self.size = poker_width, poker_height
        self.allow_stretch = True
        self.keep_ratio = False

        self.idx = idx
        self.type = -1 if idx < 48 else (idx - 48) / 20
        self.name = name
        self.selected = False
开发者ID:maopao-691515082,项目名称:cjbp4,代码行数:10,代码来源:main.py

示例15: on_check

    def on_check(self, instance, value):
        sheepimg = Image(source='images/TXT_BRAVO_MOUTONS.png', size_hint=(None, None), size=(300, 150))
        self.add_widget(sheepimg)
        sheepimg.pos = (300, 300)

        self.button = BtnOk(scenario=self)
        self.button.center = (630, 270)
        self.button.button.background_normal = 'images/BUT_OK_UNVALID.png'
        self.button.button.background_down = 'images/BUT_OK_VALID.png'
        self.add_widget(self.button)
开发者ID:museomix,项目名称:2013-gens_de_lalpe,代码行数:10,代码来源:main.py


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