Esempio n. 1
0
	def _setup(self, i, a, c):
		
		if a != None:
			c['accessory']=scene.SpriteNode(
				texture=a,
				size=(self.size[1]/4, self.size[1]/5*1.5),
				position=scene.Point(-self.size[0]/2+7, self.size[1]/2-10),
				parent=self,
				z_position=4,
				color=self.accessoryColor)
			
		if i != None:
			c['icon']=scene.SpriteNode(
				texture=i,
				size=scene.Size(self.size[1]/2, self.size[1]/2),
				position=scene.Point(self.w/2 - self.size[1]/3 , 0),
				parent=self, 
				z_position=9)
				
		if self.text:
			c['label']=scene.LabelNode(
				text=self.text,
				font=(self.font_family, self.font_size),
				position=scene.Point(0 , 0),
				anchor_point=(0.5, 0.5),
				color=self.text_color,
				parent=self,
				z_position=10)
Esempio n. 2
0
    def setup(self):
        self.button_dict = collections.OrderedDict([
            ('+', self.increase_font_size), ('—', self.decrease_font_size),
            ('Font', self.next_font), ('Color', self.next_color),
            ('Save', self.save_image), ('Cancel', self.cancel)
        ])

        fgColor = scene.Color(*color('black'))
        bgColor = scene.Color(*color('grey'))
        loc = [0, 0]
        for button_text in self.button_dict:
            if button_text == '+':
                button_text = '  +  '  # double spaces around '+'
            else:  # single space around others
                button_text = ' ' + button_text + ' '
            theButton = TextButton(self, loc, button_text, fgColor, bgColor)
            self.btn_height = max(self.btn_height, theButton.frame.h)
            loc[0] += theButton.frame.w + 4  # 4 pixels between each button

        self.picratio = self.picsize.w / (self.picsize.h * 1.0)
        usable_space = self.bounds.h - self.btn_height
        x = usable_space * self.picratio
        if x <= self.bounds.w:
            y = usable_space
        else:
            x = self.bounds.w
            y = self.bounds.w / self.picratio
        self.position = scene.Size(x / 2, y / 2)  # no ...y/2+self.btn_height
        self.picscale = self.picsize[0] / (x * 1.0)
        self.layer = scene.Layer(scene.Rect(0, self.btn_height, x, y))
        self.layer.image = scene.load_pil_image(self.img)
        self.add_layer(self.layer)
Esempio n. 3
0
 def __init__(self):
     self.img2 = photos.pick_image()
     self.img = self.img2.convert('RGBA') #fix for current scene.load_pil_image()
     if self.img:
         self.picsize = scene.Size(*self.img.size)
         scene.run(self)
     else:
         print('Good bye!')
Esempio n. 4
0
 def __init__(self):
     self.text = raw_input(
         'Text to insert in the picture [Hello]: ') or 'Hello'
     self.position = None
     self.fontnr = 0  # Helvetica
     self.colornr = 3  # red
     self.fontsize = 48.0  # 48 point
     self.img2 = photos.pick_image()
     self.img = self.img2.convert(
         'RGBA')  #fix for current scene.load_pil_image()
     self.picsize = scene.Size(*self.img.size)
     self.btn_height = 0
     if self.img:
         scene.run(self, frame_interval=3
                   )  # save battery with less frame rates -> 3 = 20fps
     else:
         print('Good bye!')
 def __init__(self):
     scene.Scene.__init__(self)
     self.distance_old = 0.0
     self.distance_new = 0.0
     self.distance_abs = 0.0
     self.reset = True
     self.zoom = 1.0  #no zoom
     self.zoom_min = 0.5
     self.zoom_max = 5
     self.zoom_speed = 3
     self.img2 = photos.pick_image()
     self.img = self.img2.convert(
         'RGBA')  #fix for current scene.load_pil_image()
     if self.img:
         self.picsize = scene.Size(*self.img.size)
         scene.run(self)
     else:
         print('Good bye!')
Esempio n. 6
0
    def __init__(self, screen, w, h):
        self.size = scene.Size(w, h)
        w, h = (screen.w / w, screen.h / h)
        self.cells = {(x, y): Cell(x, y, scene.Rect(x * w, y * h, w, h))
                      for x in xrange(self.size.w)
                      for y in xrange(self.size.h)}
        grid_img = Image.new('RGBA', [int(i) for i in screen.as_tuple()])
        grid_draw = ImageDraw.Draw(grid_img)

        for x in xrange(self.size.w):
            grid_draw.line((x * w, 0, x * w, screen.h))
        x = self.size.w
        grid_draw.line((x * w - 1, 0, x * w - 1, screen.h))

        for y in xrange(self.size.h):
            grid_draw.line((0, y * h, screen.w, y * h))
        y = self.size.h
        grid_draw.line((0, y * h - 1, screen.w, y * h - 1))
        self.grid_img = scene.load_pil_image(grid_img)
        del grid_img, grid_draw
Esempio n. 7
0
    def __init__(self):
        self.view = ui.load_view('PhotoTextV2')
        self.set_button_actions()
        self.view.present('full_screen')

        img = photos.pick_image()
        if img:
            console.hud_alert('Please wait...')
            scale = scene.get_screen_scale()
            #print str(scale)
            picsize = scene.Size(*img.size)
            width = picsize[0] / scale
            height = picsize[1] / scale
            self.sv2 = self.view['scrollview2']
            self.sv2.content_size = (width, height)
            self.sv2v1 = self.sv2.subviews[0]  #sv2v1 = view1 in scrollview2
            self.sv2v1.bounds = (0, 0, width, height)
            self.sceneView = scene.SceneView(frame=self.sv2v1.bounds)
            self.sceneView.scene = MyPicture(self.view['scrollview1'].subviews[0].text, img, picsize)
            img = None
            self.sv2.add_subview(self.sceneView)
        else:
            self.view.close()
Esempio n. 8
0
class Tick:
	val=0.0 
	last_tick=0.0
	intervals=1.0
	objects_to_update=[]
	label=scene.LabelNode(text='Tick: ', color=(0.0, 0.0, 0.0, 1.0), 
					size=scene.Size(50, 35), anchor_point=(0.0, 0.0))
	
	@classmethod
	def dt(cls): 
		return round(cls.val, 3)
		
	@classmethod
	def set(cls, val):
		cls.last_tick=cls.val
		cls.val=val
		if cls.val < cls.last_tick:
			cls.label.color=(0.0, 0.75, 0.0)
			cls.label.text=f'Tick: {cls.dt()}'
		else:
			cls.label.color=(0.75, 0.0, 0.0)
			cls.label.text=f'Tick: {cls.dt()}'
      
	@classmethod
	def size(cls):
		return len(cls.objects_to_update)
		
	@classmethod
	def Add(cls, object): 
		cls.objects_to_update.append(object)
		
	@classmethod
	def _update(cls, GameLoop):
		cls.set(GameLoop.dt)
		if cls.objects_to_update:
			for child in cls.objects_to_update:
				child.update()
Esempio n. 9
0
 def setup(self):
     w, h = self.picsize
     self.textPosition = scene.Size(w/2/self.scale, h/2/self.scale)
     self.layer = scene.Layer(scene.Rect(0, 0, w/2, h/2))
     self.layer.image = scene.load_pil_image(self.img)
     self.add_layer(self.layer)
Esempio n. 10
0
 def reset(self, position_x):
     x = self.scene_size_x + random.randrange(0, 500, 80) - position_x
     y = 10
     self.left_buttom_coord = scene.Size(x, y)
     self.update_img()