本文整理汇总了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)
示例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
示例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
示例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
示例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
示例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
示例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)
示例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
示例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
示例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
示例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)
示例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")
示例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)
示例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
示例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)