Esempio n. 1
0
 def _anim_current_error_color(self, color, duration=0.2):
     # https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/_anim_current_error_color_to_disabled_color.gif
     # https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/_anim_current_error_color_to_fade.gif
     Animation(duration=duration, _current_error_color=color).start(self)
Esempio n. 2
0
 def show_menu_list_animation(self):
     Animation(y=dp(60), d=.6, t='out_elastic').start(self.ids.menu_dialog)
     self.menu_open = True
Esempio n. 3
0
 def hide_menu_animation(self):
     Animation(x=Window.width, d=.2).start(self.ids.top_menu)
     anim = Animation(x=-Window.width, d=.2)
     anim.bind(on_complete=self.back_to_previous_screen)
     anim.start(self.ids.bottom_menu)
Esempio n. 4
0
    def on_focus(self, *args):
        Animation.cancel_all(self, '_line_width', '_hint_y',
                             '_hint_lbl_font_size')
        if self.max_text_length is None:
            max_text_length = sys.maxsize
        else:
            max_text_length = self.max_text_length
        if len(self.text) > max_text_length or all(
            [self.required,
             len(self.text) == 0, self.has_had_text]):
            self._text_len_error = True
        if self.error or all([
                self.max_text_length is not None
                and len(self.text) > self.max_text_length
        ]):
            has_error = True
        else:
            if all([self.required, len(self.text) == 0, self.has_had_text]):
                has_error = True
            else:
                has_error = False

        if self.focus:
            self.has_had_text = True
            Animation.cancel_all(self, '_line_width', '_hint_y',
                                 '_hint_lbl_font_size')
            if len(self.text) == 0:
                Animation(_hint_y=dp(14),
                          _hint_lbl_font_size=sp(12),
                          duration=.2,
                          t='out_quad').start(self)
            Animation(_line_width=self.width, duration=.2,
                      t='out_quad').start(self)
            if has_error:
                Animation(duration=.2,
                          _current_hint_text_color=self.error_color,
                          _current_right_lbl_color=self.error_color,
                          _current_line_color=self.error_color).start(self)
                if self.helper_text_mode == "on_error" and (
                        self.error or self._text_len_error):
                    Animation(
                        duration=.2,
                        _current_error_color=self.error_color).start(self)
                elif self.helper_text_mode == "on_error" and not self.error and not self._text_len_error:
                    Animation(duration=.2,
                              _current_error_color=(0, 0, 0, 0)).start(self)
                elif self.helper_text_mode == "persistent":
                    Animation(duration=.2,
                              _current_error_color=self.theme_cls.
                              disabled_hint_text_color).start(self)
                elif self.helper_text_mode == "on_focus":
                    Animation(duration=.2,
                              _current_error_color=self.theme_cls.
                              disabled_hint_text_color).start(self)
            else:
                Animation(duration=.2,
                          _current_hint_text_color=self.line_color_focus,
                          _current_right_lbl_color=self.theme_cls.
                          disabled_hint_text_color).start(self)
                if self.helper_text_mode == "on_error":
                    Animation(duration=.2,
                              _current_error_color=(0, 0, 0, 0)).start(self)
                if self.helper_text_mode == "persistent":
                    Animation(duration=.2,
                              _current_error_color=self.theme_cls.
                              disabled_hint_text_color).start(self)
                elif self.helper_text_mode == "on_focus":
                    Animation(duration=.2,
                              _current_error_color=self.theme_cls.
                              disabled_hint_text_color).start(self)
        else:
            if len(self.text) == 0:
                Animation(_hint_y=dp(38),
                          _hint_lbl_font_size=sp(16),
                          duration=.2,
                          t='out_quad').start(self)
            if has_error:
                Animation(
                    duration=.2,
                    _current_line_color=self.error_color,
                    _current_hint_text_color=self.error_color,
                    _current_right_lbl_color=self.error_color).start(self)
                if self.helper_text_mode == "on_error" and (
                        self.error or self._text_len_error):
                    Animation(
                        duration=.2,
                        _current_error_color=self.error_color).start(self)
                elif self.helper_text_mode == "on_error" and not self.error and not self._text_len_error:
                    Animation(duration=.2,
                              _current_error_color=(0, 0, 0, 0)).start(self)
                elif self.helper_text_mode == "persistent":
                    Animation(duration=.2,
                              _current_error_color=self.theme_cls.
                              disabled_hint_text_color).start(self)
                elif self.helper_text_mode == "on_focus":
                    Animation(duration=.2,
                              _current_error_color=(0, 0, 0, 0)).start(self)
            else:
                Animation(duration=.2,
                          _current_line_color=self.line_color_focus,
                          _current_hint_text_color=self.theme_cls.
                          disabled_hint_text_color,
                          _current_right_lbl_color=(0, 0, 0, 0)).start(self)
                if self.helper_text_mode == "on_error":
                    Animation(duration=.2,
                              _current_error_color=(0, 0, 0, 0)).start(self)
                elif self.helper_text_mode == "persistent":
                    Animation(duration=.2,
                              _current_error_color=self.theme_cls.
                              disabled_hint_text_color).start(self)
                elif self.helper_text_mode == "on_focus":
                    Animation(duration=.2,
                              _current_error_color=(0, 0, 0, 0)).start(self)

                Animation(_line_width=0, duration=.2, t='out_quad').start(self)
Esempio n. 5
0
 def add_custom_toolbar(self):
     toolbar = self.ids.toolbar
     Animation(y=Window.height - toolbar.height, d=.3).start(toolbar)
Esempio n. 6
0
 def rotate_eyes(self, max_angle, duration):
     self.eye_animation = (Animation(rot_angle=max_angle, d=duration) +
                           Animation(rot_angle=0, d=duration))
     self.eye_animation.repeat = True
     self.eye_animation.start(self)
Esempio n. 7
0
 def brakeMessage(self, status):
     if status == 'up':
         anim = Animation(y=0, opacity=1, duration=.5, t='in_out_quint')
     if status == 'down':
         anim = Animation(y=10, opacity=0, duration=.2, t='out_back')
     anim.start(self.ids['breakLeverMessage'])
Esempio n. 8
0
 def start_animation_0(self, trigger=None, value=None):
     self.pos_0 = self.offsets[0]
     anim = Animation(pos_0=1+self.offsets[0], duration=self.speeds[0])
     anim.start(self)
Esempio n. 9
0
 def start_animation_1(self, trigger=None, value=None):
     self.pos_1 = self.offsets[1]
     anim = Animation(pos_1=1+self.offsets[1], duration=self.speeds[1])
     anim.start(self)
Esempio n. 10
0
 def _hide_bubble(self):
     self.alpha = 1.
     Animation(alpha=0, d=4, t='in_out_expo').start(self)
Esempio n. 11
0
 def start_animation_2(self, trigger=None, value=None):
     self.angle_2 = self.offsets[2]
     anim = Animation(angle_2=360+self.offsets[2], duration=self.speeds[2])
     anim.start(self)
Esempio n. 12
0
 def _bind_inactive_bar_color(self, *l):
     self.funbind('bar_color', self._change_bar_color)
     self.fbind('bar_inactive_color', self._change_bar_color)
     Animation(_bar_color=self.bar_inactive_color, d=.5,
               t='out_quart').start(self)
Esempio n. 13
0
 def animate(self, instance):
      animation = Animation(pos=(0, 5), t='out_bounce',duration= 0.2)
      animation += Animation(pos=(0, 0), t='out_bounce',duration= 0.2)
      animation.start(instance)
Esempio n. 14
0
    def on_focus(self, *args):
        disabled_hint_text_color = self.theme_cls.disabled_hint_text_color
        Animation.cancel_all(
            self, "_line_width", "_hint_y", "_hint_lbl_font_size"
        )
        self._set_text_len_error()

        if self.focus:
            self._line_blank_space_right_point = (
                self._get_line_blank_space_right_point()
            )
            _fill_color = self.fill_color
            _fill_color[3] = self.fill_color[3] - 0.1
            Animation(
                _line_blank_space_right_point=self._line_blank_space_right_point,
                _line_blank_space_left_point=self._hint_lbl.x - dp(5),
                _current_hint_text_color=self.line_color_focus,
                fill_color=_fill_color,
                duration=0.2,
                t="out_quad",
            ).start(self)
            self.has_had_text = True
            Animation.cancel_all(
                self, "_line_width", "_hint_y", "_hint_lbl_font_size"
            )
            if not self.text:
                self._anim_lbl_font_size(dp(14), sp(12))
            Animation(_line_width=self.width, duration=0.2, t="out_quad").start(
                self
            )
            if self._get_has_error():
                self._anim_current_error_color(self.error_color)
                if self.helper_text_mode == "on_error" and (
                    self.error or self._text_len_error
                ):
                    self._anim_current_error_color(self.error_color)
                elif (
                    self.helper_text_mode == "on_error"
                    and not self.error
                    and not self._text_len_error
                ):
                    self._anim_current_error_color((0, 0, 0, 0))
                elif self.helper_text_mode in ("persistent", "on_focus"):
                    self._anim_current_error_color(disabled_hint_text_color)
            else:
                self._anim_current_right_lbl_color(disabled_hint_text_color)
                Animation(duration=0.2, color=self.line_color_focus).start(
                    self._hint_lbl
                )
                if self.helper_text_mode == "on_error":
                    self._anim_current_error_color((0, 0, 0, 0))
                if self.helper_text_mode in ("persistent", "on_focus"):
                    self._anim_current_error_color(disabled_hint_text_color)
        else:
            _fill_color = self.fill_color
            _fill_color[3] = self.fill_color[3] + 0.1
            Animation(fill_color=_fill_color, duration=0.2, t="out_quad").start(
                self
            )
            if not self.text:
                self._anim_lbl_font_size(dp(38), sp(16))
                Animation(
                    _line_blank_space_right_point=0,
                    _line_blank_space_left_point=0,
                    duration=0.2,
                    t="out_quad",
                ).start(self)
            if self._get_has_error():
                self._anim_get_has_error_color(self.error_color)
                if self.helper_text_mode == "on_error" and (
                    self.error or self._text_len_error
                ):
                    self._anim_current_error_color(self.error_color)
                elif (
                    self.helper_text_mode == "on_error"
                    and not self.error
                    and not self._text_len_error
                ):
                    self._anim_current_error_color((0, 0, 0, 0))
                elif self.helper_text_mode == "persistent":
                    self._anim_current_error_color(disabled_hint_text_color)
                elif self.helper_text_mode == "on_focus":
                    self._anim_current_error_color((0, 0, 0, 0))
            else:
                Animation(duration=0.2, color=(1, 1, 1, 1)).start(
                    self._hint_lbl
                )
                self._anim_get_has_error_color()
                if self.helper_text_mode == "on_error":
                    self._anim_current_error_color((0, 0, 0, 0))
                elif self.helper_text_mode == "persistent":
                    self._anim_current_error_color(disabled_hint_text_color)
                elif self.helper_text_mode == "on_focus":
                    self._anim_current_error_color((0, 0, 0, 0))
                Animation(_line_width=0, duration=0.2, t="out_quad").start(self)
Esempio n. 15
0
 def set_chip_text_color(self, instance_chip, active_value: int):
     Animation(color=(0, 0, 0, 1) if active_value else (0, 0, 0, 0.5),
               d=0.2).start(self.ids.label)
Esempio n. 16
0
 def start_animation_2(self, trigger=None, value=None):
     self.pos_2 = self.offsets[2]
     anim = Animation(pos_2=1+self.offsets[2], duration=self.speeds[2])
     anim.start(self)
Esempio n. 17
0
 def close_card(self):
     anim = Animation(x=0, t=self.closing_transition, d=self.opening_time)
     anim.bind(on_complete=self._reset_open_progress)
     anim.start(self.children[0])
     self.state = "closed"
Esempio n. 18
0
 def remove(self):
     anim = Animation(height=0, double_opacity=0, d=0.9, t='out_expo')
     anim.bind(on_complete=self._remove)
     anim.start(self)
Esempio n. 19
0
    def on_update(self, *args):
        if (self.stop_time is None) or (time.time() - self.stop_time > 3):
            if self.gave_recording_feedback:
                pass
            else:
                self.process_leap()
            if self.state == 'start' and not self.is_running:
                print('Metronome has started. It is listening for input tempo.')
                if self.accomp_file:
                    self.text_feedback = 'Listening for input tempo. May take awhile to load MIDI file.'
                else:
                    self.text_feedback = 'Metronome has started. It is listening for input tempo.'

                if not self.gave_recording_feedback:
                    self.gave_recording_feedback = True
                else:
                    t_avg, bpm = record_process_signal()
                    self.gave_recording_feedback = False
                    #t_avg, bpm = 0.46, 128
                    if self.accomp_file and not self.accomp_playing:
                        #self.text_feedback = 'Playing MIDI file at your tempo, %s BPM.' % bpm
                        self.py_game = run_midi_player(self.accomp_file, bpm, 'Piano', self.controller)
                        self.accomp_playing = True

                    Animation.cancel_all(self)
                    self.dur = float(round(t_avg, 2))
                    if self.pulsing:
                        if self.block:
                            self.canvas.remove(self.block)
                            self.block = None
                        self.pulse_schedule = Clock.schedule_interval(self.blink_square, self.dur)
                    else:
                        self.animation = Animation(pos=(700, 0), duration=0.98 * self.dur) \
                                         + Animation(pos=(0, 0), duration=0.98 * self.dur)
                        self.animation.repeat = True
                        if self.block is None:
                            with self.canvas:
                                Color(BLOCK_COLOR[0], BLOCK_COLOR[1], BLOCK_COLOR[2], BLOCK_COLOR[3])
                                self.block = Rectangle(size_hint=(None, None))
                        self.animation.start(self.block)

                    self.click_schedule = Clock.schedule_interval(self.play_click, self.dur)
                    self.is_running = True
                    if self.accomp_playing:
                        self.text_feedback = 'Playing MIDI file at your tempo, %s BPM. To stop, make a fist - %s' % (round(bpm), round(self.hand.grab_strength, 2))
                    else:
                        self.text_feedback = 'Metronome is running. To stop, make a fist! Fist strength: %s' % round(self.hand.grab_strength, 2)
                    print('Metronome is running. To stop, make a fist! Fist strength: %s' % round(self.hand.grab_strength, 2))
            elif self.state == 'stop' and self.is_running:
                print('Metronome has stopped')
                self.text_feedback = 'Metronome has stopped.'
                if self.accomp_playing:
                    self.py_game.mixer.music.stop()
                    self.accomp_playing = False
                    self.accomp_file = None

                if self.pulsing:
                    if self.pulse_schedule:
                        self.pulse_schedule.cancel()
                else:
                    if self.animation:
                        self.animation.stop(self.block)
                        self.animation.repeat = False
                if self.click_schedule:
                    self.click_schedule.cancel()
                self.is_running = False
                self.stop_time = time.time()
        else:
            print('Cycle ended! Short waiting before the next cycle!')
Esempio n. 20
0
 def on_enter(self, *args):
     self._anim = Animation(timer=TIMER_TARGET_VALUE,
                            duration=random.randint(2, 5))
     self._anim.start(self)
Esempio n. 21
0
File: piece.py Progetto: fp12/yahtr
    def on_unit_skill_move(self, context):
        self.prepare_move()

        pos = self.hex_layout.hex_to_pixel(
            context.end_coords).tup if context.move_info.move else None

        anim = None
        if context.move_info.move_type == MoveType.none:
            anim = Animation(duration=0)
            if pos:
                anim &= Animation(pos=pos, duration=0.3)
            if context.move_info.orientation:
                if abs(context.target_angle - self.angle) > 180:
                    self.angle -= 360
                anim &= Animation(angle=context.target_angle, duration=0.2)

        elif context.move_info.move_type == MoveType.blink:
            anim = Animation(a=0, duration=0.1)
            if pos:
                anim += Animation(pos=pos, duration=0)
            if context.move_info.orientation:
                if abs(context.target_angle - self.angle) > 180:
                    self.angle -= 360
                anim += Animation(angle=context.target_angle, duration=0)
            anim += Animation(a=1, duration=0.2)

        elif context.move_info.move_type == MoveType.pushed:
            anim = Animation(pos=pos, duration=0.3, t='out_back')

        elif context.move_info.move_type == MoveType.jump_over_tile:
            duration = 1
            target_pos_x = self.x - (pos[0] - self.x) / 30
            target_pos_y = self.y - (pos[1] - self.y) / 30

            prep_anim = Animation(radius=self.radius * .95,
                                  duration=duration / 3)
            prep_anim &= Animation(pos=(target_pos_x, target_pos_y),
                                   duration=duration / 3)

            target_pos_x = pos[0] + (pos[0] - self.x) / 25
            target_pos_y = pos[1] + (pos[1] - self.y) / 25
            jump_anim = Animation(radius=self.radius * 1.2,
                                  duration=duration / 3,
                                  t='out_back')
            jump_anim &= Animation(pos=(target_pos_x, target_pos_y),
                                   duration=duration / 3)

            land_anim = Animation(radius=self.radius,
                                  duration=duration / 3,
                                  t='out_bounce')
            land_anim &= Animation(pos=pos, duration=duration / 3)

            anim = prep_anim + jump_anim + land_anim

        anim_scheduler.add(
            anim, self,
            context.move_info.order, lambda *args: self.on_finished_moving(
                context.end_coords, context.end_orientation))
Esempio n. 22
0
def move_car(obj, params):
    # animation = Animation(y=params, d=.5, t='out_bounce')
    animation = Animation(y=params, d=.5)
    return animation
Esempio n. 23
0
 def _set_message_mode(self, instance, text):
     self.helper_text_mode = text
     if self.helper_text_mode == "persistent":
         Animation(duration=.1,
                   _current_error_color=self.theme_cls.
                   disabled_hint_text_color).start(self)
Esempio n. 24
0
def take_item(obj, params):
    animation = Animation(width=0, height=0, d=.5)
    animation.bind(on_complete=lambda *l: params(obj))

    return animation
Esempio n. 25
0
 def show_menu_animation(self):
     Animation(x=0, d=.2).start(self.ids.top_menu)
     Animation(x=Window.width - self.ids.bottom_menu.width,
               d=.2).start(self.ids.bottom_menu)
Esempio n. 26
0
def lap(x):
    Animation(opacity=1).start(btn3)
    btn3.disabled = False
    global laps, num
    num += 1
    laps.append(label.text + ':' + label1.text + " -- " + str(num) + '\n')
Esempio n. 27
0
 def hide_menu_list_animation(self):
     Animation(y=Window.height, d=.6,
               t='in_elastic').start(self.ids.menu_dialog)
     self.menu_open = False
Esempio n. 28
0
 def on__rotation_angle(self, *args):
     if self._rotation_angle == 0:
         self._rotation_angle = 360
         if not self.determinate:
             _rot_anim = Animation(_rotation_angle=0, duration=2)
             _rot_anim.start(self)
Esempio n. 29
0
 def hide_toolbar_animation(self):
     Animation(y=Window.height, d=.2).start(self.ids.toolbar)
Esempio n. 30
0
 def _anim_current_right_lbl_color(self, color, duration=0.2):
     # https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/_anim_current_right_lbl_color.png
     Animation(duration=duration, _current_right_lbl_color=color).start(self)