Example #1
0
 def touch_moved(self, touch):
     touch_loc = self.menu_bg.point_from_scene(touch.location)
     for btn in self.buttons:
         if touch_loc in btn.frame:
             btn.texture = scene.Texture('pzl:Button2')
         else:
             btn.texture = scene.Texture('pzl:Button1')
 def update(self):
     global img_label      
     if self.sprite_label != img_label:
         if img_label == 'dog':
             self.sprite_label = 'dog'
             self.sprite.texture = scene.Texture('Dog_Face')
         else:
             self.sprite_label = 'cat'
             self.sprite.texture = scene.Texture('Cat_Face')
def domino_image(pips=(5, 6), die_size=70, fg_color='blue', bg_color='grey'):
    width = die_size * 2
    height = die_size
    with ui.ImageContext(width, height) as ctx:
        # domino is rounded rect in background color
        ui.set_color(bg_color)
        ui.Path.rounded_rect(0, 0, width, height, height / 10).fill()
        # pips are circles in foreground color
        ui.set_color(fg_color)
        pip_size = height / 3
        b = int(height / 14)
        wh = pip_size - 2 * b
        # draw pips[0]
        for loc in pip_locs[pips[0]]:
            if loc:
                x, y = loc
                ui.Path.oval(x * pip_size + b, y * pip_size + b, wh, wh).fill()
        # draw dividing line
        path = ui.Path()
        # path.line_width = 4
        path.move_to(die_size, b)
        path.line_to(die_size, height - b)
        path.close()
        path.stroke()
        # draw pips[1]
        for loc in pip_locs[pips[1]]:
            if loc:
                x, y = loc
                ui.Path.oval(x * pip_size + b + die_size, y * pip_size + b, wh,
                             wh).fill()
        return scene.Texture(ctx.get_image())
Example #4
0
def get_texture_and_duration(pil_image):
        duration = 4.0 / 60  # hardcoded!!
        new_im = PIL_Image.new("RGBA", pil_image.size)
        new_im.paste(pil_image)
        with io.BytesIO() as mem_file:
            new_im.save(mem_file, format='PNG')
            return (scene.Texture(ui.Image.from_data(mem_file.getvalue())),
                    duration)
Example #5
0
 def setup(self):
     tile_texture = scene.Texture(ui.Image.named('Snake'))
     self.sprite = scene.SpriteNode(tile_texture,
                                    size=(500, 500),
                                    parent=self)
     self.sprite.shader = scene.Shader(shader_text)
     self.sprite.position = self.size / 2
     self.state = 0.0
Example #6
0
def make_oval_sprite(width=100, height=100, fg_color='blue', bg_color='grey'):
    with scene.ui.ImageContext(width, height) as ctx:
        scene.ui.set_color(bg_color)
        scene.ui.Path.rounded_rect(0, 0, width, height, height / 10).fill()
        scene.ui.set_color(fg_color)
        scene.ui.Path.oval(0, 0, width, height).fill()
        return ctx.get_image()
        return scene.Texture(ctx.get_image())
Example #7
0
 def setup(self):
     tile_texture = scene.Texture(ui.Image.named('Snake'))
     self.sprite = scene.SpriteNode(tile_texture,
                                    size=(600, 600),
                                    anchor_point=(0, 0),
                                    parent=self)
     self.sprite.shader = scene.Shader(shader_text)
     self.sprite.position = (100, 100)
Example #8
0
 def setup(self):
     self.background_color = 'gray'
     self.sprite = scene.SpriteNode(
         scene.Texture(myscene_shape_parameters.image),
         position=(self.size[0] / 2, self.size[1] / 2),
         size=self.size,
         anchor_point=(.5, .5),
         parent=self)
 def setup(self):
     self.im = PILImage.open('tunnelswirl.gif')
     self.mypalette = self.im.getpalette()
     self.savefile = 'tmp.png'
     self.toggle_state = False
     self.sprite = scene.SpriteNode(scene.Texture(ui.Image.named('Snake')),
                                    position=self.size / 2,
                                    parent=self)
Example #10
0
 def setup(self):
     self.background_color = 'white'
     self.toggle_state = False
     snake = scene.Texture(ui.Image.named('Snake'))
     self.sprite0 = scene.SpriteNode(snake, position=self.size / 2,
                                     parent=self)
     # self.sprite1 = GifSpriteNode('tunnelswirl.gif',
     #                             position=self.size / 2)
     self.sprite1 = GifSpriteNode(filename, position=self.size / 2)
Example #11
0
 def update_image(self, newimage):
     new_image = ui.Image.from_data(
         newimage)  # convert raw binary to ui.image object
     if not self.player:  # init new spritenote if not exited yet (first-time run)
         self.player = scene.SpriteNode(
             scene.Texture(new_image),
             parent=self,
         )  # create spritenode texture
         if new_image.size[0] / new_image.size[
                 1] >= self.scrnratio:  # image resizing (shrink to fit narrow-side screen)
             self.player.scale = self.scrnWdth / new_image.size[
                 0]  # fit width
         else:
             self.player.scale = self.scrnHght / new_image.size[
                 1]  # fit height
         self.player.position = (self.cen_xpos, self.cen_ypos)
     else:
         self.player.texture = scene.Texture(
             new_image)  # update spritenode texture
Example #12
0
 def get_texture_and_duration(self):
     self.pilimage.putpalette(self.palette)
     duration = self.pilimage.info['duration']/100.0
     if duration <= 0:
         duration = self.default_duration
     new_im = PILImage.new("RGBA", self.pilimage.size)
     new_im.paste(self.pilimage)
     self.savefile.seek(0)
     new_im.save(self.savefile, format='PNG')
     return (scene.Texture(ui.Image.from_data(self.savefile.getvalue())), duration)
 def setup(self):
     img = ui.Image.named('plf:HudPlayer_yellow')
     w, h = img.size
     with ui.ImageContext(w, h) as ctx:
         img.draw(0, 0, w, h)
         path = ui.Path.rect(0, 0, w, h)
         ui.set_color('red')
         path.stroke()
         img1 = ctx.get_image()
     self.sprite_node = scene.SpriteNode(scene.Texture(img1),
                                         position=self.size / 2,
                                         parent=self)
Example #14
0
 def setup(self):
     self.toggle_state = False
     self.sprite0 = scene.SpriteNode(scene.Texture(ui.Image.named('Snake')),
         position=self.size/2,
         parent=self)
     self.sprite1 = GifSpriteNode('tunnelswirl.gif', preload=False,
         position=self.size/2)
     #self.sprite1 = GifSpriteNode('tunnelswirl.gif', preload=True,
     #    position=self.size/2)
     '''self.sprite1 = GifSpriteNode('test_image1.gif', preload=True,
         position=self.size/2)'''
     '''self.sprite1 = GifSpriteNode('tumblr_mh8uaqMo2I1rkp3avo2_250.gif', preload=True,
Example #15
0
 def touch_ended(self, touch):
     touch_loc = self.menu_bg.point_from_scene(touch.location)
     if touch.location not in self.menu_bg.frame:
         self.presenting_scene.dismiss_modal_scene()
     for btn in self.buttons:
         btn.texture = scene.Texture('pzl:Button1')
         if self.presenting_scene and touch_loc in btn.frame:
             new_title = self.presenting_scene.menu_button_selected(
                 btn.title)
             if new_title:
                 btn.title = new_title
                 btn.title_label.text = new_title
 def update(self):
     if self.toggle_state:
         try:
             self.im.putpalette(self.mypalette)
             new_im = PILImage.new("RGBA", self.im.size)
             new_im.paste(self.im)
             new_im.save(self.savefile)
             self.sprite.texture = scene.Texture(
                 ui.Image.named(self.savefile))
             self.im.seek(self.im.tell() + 1)
         except EOFError:
             self.im.seek(0)
Example #17
0
    def touch_ended(self, touch: scene.Touch) -> None:
        touch_loc = self.menu_bg.point_from_scene(touch.location)
        for node in self.nodes:
            node.texture = scene.Texture("pzl:Button1")

            if touch_loc in node.frame:
                '''  
                if node.title == "Options":
                    self.present_modal_scene(OptionsMenu())
                    break
                '''
                if self.presenting_scene:
                    self.presenting_scene.menu_button_selected(node.title)
 def setup(self):
     tile_texture = scene.Texture(ui.Image.named('Snake'))
     self.sprite = scene.SpriteNode(tile_texture,
                                    size=(500, 500),
                                    parent=self)
     self.sprite.shader = scene.Shader(shader_text)
     self.sprite.position = self.size / 2
     self.state = 0.0
     self.record_start = scene.LabelNode('Start_Recording',
                                         position=scene.Point(350, 50),
                                         parent=self)
     self.record_stop = scene.LabelNode('Stop_Recording',
                                        position=scene.Point(650, 50),
                                        parent=self)
Example #19
0
	def get_texture_and_duration(self):
		if not self.pilimage.getpalette():
			self.pilimage.putpalette(self.palette)
		duration = self.pilimage.info['duration']/100.0
		if duration <= 0:
			duration = self.default_duration
		new_im = PILImage.new("RGBA", self.pilimage.size)
		if self.mode == 'partial':
			new_im.paste(self.last_frame)
		new_im.paste(self.pilimage, (0,0), self.pilimage.convert('RGBA'))
		self.last_frame = new_im
		self.savefile.seek(0)
		new_im.save(self.savefile, format='PNG')
		return (scene.Texture(ui.Image.from_data(self.savefile.getvalue())), duration)
Example #20
0
		def setup(self):
			self.toggle_state = False
			self.sprite0 = scene.SpriteNode(scene.Texture(ui.Image.named('Snake')),
			position=self.size/2,
			parent=self)
			'''self.sprite1 = GifSpriteNode('tunnelswirl.gif', preload=False,
			position=self.size/2)'''
			self.sprite1 = GifSpriteNode('tunnelswirl.gif', preload=True,
			position=self.size/2)
			'''self.sprite1 = GifSpriteNode('tumblr_mh8uaqMo2I1rkp3avo2_250.gif', preload=True,
			position=self.size/2)'''
			'''self.sprite1 = GifSpriteNode('EBY-nanoface-Pennywise-03k-40x.gif', preload=False,
			size=(400, 400),
			position=self.size/2)'''
			#gif from wikipedia gif page
			'''self.sprite1 = GifSpriteNode('Rotating_earth_(large).gif', preload=False,
			position=self.size/2)'''
			'''self.sprite1 = GifSpriteNode('9HjM5.gif', preload=True,
			position=self.size/2)'''
			'''self.sprite1 = GifSpriteNode('test_image1.gif', preload=True,
 def touch_began(self, touch):
     self.toggle_state = not self.toggle_state
     if not self.toggle_state:
         self.sprite.texture = scene.Texture(ui.Image.named('Snake'))
Example #22
0
 def touch_began(self, touch):
     touch_loc = self.menu_bg.point_from_scene(touch.location)
     for btn in self.buttons:
         if touch_loc in btn.frame:
             sound.play_effect('8ve:8ve-tap-resonant')
             btn.texture = scene.Texture('pzl:Button2')
Example #23
0
# ---[ Imports
from __future__ import division

import scene as sc
import numpy as np
import sound
import random

# ---[ Textures
jumping_texture = sc.Texture('plf:AlienPink_jump')
landing_texture = sc.Texture('plf:AlienPink_duck')
dead_texture = sc.Texture('plf:AlienPink_hit')

Monster_textures = {
    'bee': [
        sc.Texture('plf:Enemy_Bee'),
        sc.Texture('plf:Enemy_Bee_move'),
        sc.Texture('plf:Enemy_Bee_dead')
    ],
    'fly': [
        sc.Texture('plf:Enemy_Fly'),
        sc.Texture('plf:Enemy_Fly_move'),
        sc.Texture('plf:Enemy_Fly_dead')
    ],
    'frog': [
        sc.Texture('plf:Enemy_Frog'),
        sc.Texture('plf:Enemy_Frog_move'),
        sc.Texture('plf:Enemy_Frog_dead')
    ],
    'fish': [
        sc.Texture('plf:Enemy_FishPink'),
def texture_from_path(path, fill_color, width, height):
    with ui.ImageContext(width, height) as ctx:
        ui.set_color(fill_color)
        path.fill()
        img = ctx.get_image()
    return scene.Texture(img)
Example #25
0
 def update(self):
     self.sprite.texture = scene.Texture(myscene_shape_parameters.image)
Example #26
0
	def _init_textures(self, img):
		if type(img) == str or type(img) == scene.ui.Image:
			return scene.Texture(img)
		else:
			return None
Example #27
0
 def touch_began(self, touch: scene.Touch) -> None:
     touch_loc = self.menu_bg.point_from_scene(touch.location)
     for node in self.nodes:
         if touch_loc in node.frame:
             node.texture = scene.Texture("pzl:Button2")
	def setup(self):
		self.snake = scene.SpriteNode(parent=self, position=self.bounds.center(),
		texture=scene.Texture('emj:Snake'))