Esempio n. 1
0
 def on_enter(self, *args):
     self.layout = RelativeLayout()
     self.carousel = MenuCarousel(direction='right')
     w = EffectWidget()
     bg = Image(source='data/images/animation.zip', allow_stretch=True, keep_ratio=False)
     w.add_widget(bg)
     w.effects = [FXAAEffect()]
     self.carousel.add_widget(self.menu())
     self.carousel.add_widget(self.new_game_menu())
     self.layout.add_widget(w)
     self.layout.add_widget(self.carousel)
     self.add_widget(self.layout)
     Window.bind(mouse_pos=self.on_mouse_pos)
Esempio n. 2
0
    def __init__(self, mc, config, key=None, **kwargs):
        super().__init__(mc=mc, config=config, key=key)

        self.source = self.mc.displays[self.config['source_display']]

        stencil = StencilView(size_hint=(None, None),
                              size=(self.source.config['width'],
                                    self.source.config['height']))

        # Add the effects to make this look like a DMD
        effect_list = list()

        if 'luminosity' in self.config:
            effect_list.append(Monochrome(r=self.config['luminosity'][0],
                                          g=self.config['luminosity'][1],
                                          b=self.config['luminosity'][2]))

        if self.config['shades']:
            effect_list.append(Reduce(shades=self.config['shades']))

        if self.config['pixel_color']:
            effect_list.append(Colorize(r=self.config['pixel_color'][0],
                                        g=self.config['pixel_color'][1],
                                        b=self.config['pixel_color'][2]))

        if self.config['gain'] != 1.0:
            effect_list.append(Gain(gain=self.config['gain']))

        effect = EffectWidget()
        effect.effects = effect_list

        stencil.add_widget(effect)

        self.add_widget(stencil)

        try:
            effect.add_widget(self.source)
        except WidgetException:
            self.source.parent = None
            effect.add_widget(self.source)

        effect.size = (self.config['width'], self.config['height'])

        effect.texture.mag_filter = 'nearest'
        effect.texture.min_filter = 'nearest'

        self.scale = min(self.width / self.source.width,
                         self.height / self.source.height)

        self.pos = (0, 0)
Esempio n. 3
0
    def _update_electrodes(self):
        self.clear_widgets()

        # Create LED layout
        led_layer = BoxLayout(orientation='horizontal', size=self.size, pos=self.pos)
        # Create diffuser on top of LED layout
        led_diffuser = EffectWidget()
        led_diffuser.effects = []
        if self.diffuser_width >= 0:
            led_diffuser.effects.append(HorizontalBlurEffect(size=self.diffuser_width))
        led_diffuser.add_widget(led_layer)
        self.add_widget(led_diffuser)

        # Fix ids reference since kivy doesn't have built-in mechanics to do it
        self.ids['led_diffuser'] = weakref.proxy(led_diffuser)
        led_diffuser.ids['leds'] = weakref.proxy(led_layer)

        if self.slider_layout == 'diva':
            self.electrodes = 32
            self.leds = 32
            electrode_layer = BoxLayout(orientation='horizontal', size=self.size, pos=self.pos)
            for i in range(self.electrodes):
                electrode_layer.add_widget(ElectrodeWidget(electrode_index=i, top_slider_object=self))
            for i in range(self.leds):
                led_layer.add_widget(LEDWidget(led_index=i, top_slider_object=self))
            self.add_widget(electrode_layer)
            self.ids['electrodes'] = weakref.proxy(electrode_layer)
        elif self.slider_layout == 'chu':
            self.electrodes = 32
            self.leds = 31
            electrode_layer = GridLayout(rows=2)
            for i in range(self.electrodes):
                # Calculate the actual ID according to widget insertion sequence
                r = i // 16
                c = 15 - (i % 16)
                electrode_index = c * 2 + r
                electrode_layer.add_widget(ElectrodeWidget(electrode_index=electrode_index, top_slider_object=self))
            for i in range(self.leds):
                if i % 2 == 1:
                    # Partition
                    led_layer.add_widget(LEDWidget(led_index=self.leds-1-i, width=3, size_hint=(None, 1.0), top_slider_object=self))
                else:
                    # Panel
                    led_layer.add_widget(LEDWidget(led_index=self.leds-1-i, top_slider_object=self))
            self.add_widget(electrode_layer)
            self.ids['electrodes'] = weakref.proxy(electrode_layer)
Esempio n. 4
0
 def build(self):
     b = BoxLayout()
     b.add_widget(Button())
     return BoxLayoutKv()
     b = BoxLayout(orientation='vertical')
     b.add_widget(
         AnchorLagout(Button(size_hint=(.9, .2), pos_hint={'right': 1})))
     b.add_widget(Button())
     return b
     return Button1()
     return Popup(title='Test popup',
                  content=Label(text='Hello world'),
                  size_hint=(None, None),
                  size=(400, 400))
     return FileChooserListView()
     w = EffectWidget()
     w.add_widget(Button(text='Hello!'))
     w.effects = [InvertEffect(), HorizontalBlurEffect(size=2.0)]
Esempio n. 5
0
    def _setup_fbo(self, element, settings):
        """Setup FBO for a display."""
        source = self.machine.displays[element]

        # put the widget canvas on a Fbo
        texture = Texture.create(size=source.size, colorfmt='rgb')
        fbo = Fbo(size=source.size, texture=texture)

        effect_widget = EffectWidget()

        effect_list = list()

        effect_widget.effects = effect_list
        effect_widget.size = source.size

        fbo.add(effect_widget.canvas)

        return [fbo, effect_widget, source, settings, True]
Esempio n. 6
0
    def btnPress(self, *args):
        self.settings.counter += 1
        # всплывает попап с отмазкой
        excuse = self.excuses[randint(0, len(self.excuses) - 1)]
        # textLabel = Label(text=markup_text(size=80, color='000000', text=exсuse, bold=False), markup=True, size_hint=(0.8, 0.8), valign='top')
        # textLabel.bind(size=textLabel.setter('text_size'))
        # popup = ModalView(title="ОТМАЗКА НА СЕГОДНЯ",
        #               title_color=(0x75 / 255.0, 0x86 / 255.0, 0x8F / 255.0, 1),  # 75868F
        #               title_size=46 / divider,
        #               #background='white',
        #               background_color=(1, 1, 1, 0),
        #               separator_color=(1, 1, 1, 1),
        #               content=textLabel,
        #               size_hint=(.7, .5))

        popup = ModalView(size_hint=[0.8, 0.6])
        effectWidget = EffectWidget(size_hint=[1.2, 1.2])
        effectLayout = AnchorLayout(anchor_x='center', anchor_y='center', size_hint=[1, 1])
        popupWidget = RoundedWidget(size_hint=[0.9, 0.9], background_color=(1, 1, 1, 1), shadow_color=(70, 70, 70, 1))
        widgetLayout = BoxLayout(orientation='vertical')

        def popupUpdate(instance, *args):
            x, y = instance.size
            widgetLayout.size = (x - 100, y - 100)
            w, h = instance.pos
            widgetLayout.pos = (w + 50, h + 50)

        popupWidget.bind(size=popupUpdate, pos=popupUpdate)  # popupButton.setter('text_size'))
        captionLabel = Label(text=markup_text(size=46, color='75868F', text='ОТМАЗКА НА СЕГОДНЯ', font='Roboto-Black'), markup=True, size_hint=(1, 0.35), valign='top', halign='left')
        captionLabel.bind(size=captionLabel.setter('text_size'))
        textLabel = Button(text=markup_text(size=80, color='000000', text=excuse, bold=False), markup=True, size_hint=(1, 0.65), valign='top', halign='left', background_color=(0, 0, 0, 0), on_press=popup.dismiss)
        textLabel.bind(size=textLabel.setter('text_size'))
        widgetLayout.add_widget(captionLabel)
        widgetLayout.add_widget(textLabel)
        popupWidget.add_widget(widgetLayout)
        effectLayout.add_widget(popupWidget)
        effectWidget.add_widget(effectLayout)
        effectWidget.effects = [DropShadowEffect(radius=SHADOW_RADIUS / divider, tint=[0, 0, 0, 0.7])]
        popup.add_widget(effectWidget)
        popup.background_color = (0.2, 0.2, 0.2, 0.6)

        popup.open()
Esempio n. 7
0
    def _setup_fbo(self, element, settings):
        """Setup FBO for a display."""
        if element not in self.machine.displays:
            raise AssertionError(
                "Display {} not found. Please create it to use display_light_player."
                .format(element))
        source = self.machine.displays[element]

        # put the widget canvas on a Fbo
        texture = Texture.create(size=source.size, colorfmt='rgb')
        fbo = Fbo(size=source.size, texture=texture)

        effect_widget = EffectWidget()

        effect_list = list()

        effect_widget.effects = effect_list
        effect_widget.size = source.size

        fbo.add(effect_widget.canvas)

        return [fbo, effect_widget, source, settings, True]
Esempio n. 8
0
    def __init__(self, start_pos, end_pos):
        xpos = start_pos[0]
        tlx = Settings.GAME_ZONE_TOPLEFT_CORNER[0]

        if xpos < tlx + 106:
            self.type = 'triangle'
        elif xpos < tlx + 106 * 2:
            self.type = 'box'
        elif xpos < tlx + 106 * 3:
            self.type = 'circle'
        else:
            raise Exception('Wrong start pos %s' % xpos)

        w = EffectWidget(
            size = (45, 45),
            background_color = (0,0,0,0),
            pos = start_pos
        )
        w.effects = [effects_map.get(self.type)()]

        self.widget = w

        self.speed = 5
        self.dir_vector = (Vector(*end_pos) - Vector(*start_pos)).normalize()
Esempio n. 9
0
 def build(self):
     w = EffectWidget()
     w.add_widget(Button(text='Hello!'))
     w.effects = [InvertEffect(), HorizontalBlurEffect(size=5.0)]
     return w