带有动画Kivy的文本模糊

时间:2019-01-10 05:13:13

标签: python kivy

因此,使用奇异特式动画将文本缩放为1.1时,文本变得模糊。我敢肯定这是因为字体大小在整个过程中都是静态的,因此正在被拉伸。

是否可以使用动画来增加文本的比例大小,同时保持其清晰度?

我还注意到一个奇怪的问题,当它们放大时,上面的所有其他小部件也会被推入。我正在尝试将其本地化。这是我的.kv文件。

Builder.load_string("""
#:import F kivy.factory.Factory
#:import HoverButton BasicUI.HoverButton
#:import changeTypeToId Database.changeTypeToId
#:import utils kivy.utils


<ChangeButton@HoverButton>:
    background_color: 0, 0, 0, 1
    markup: True
    font_size: 32
    size_hint: None, None
    width:  self.texture_size[0] + 5
    height: self.texture_size[1] + 5 if self.texture_size[1] != 0 else 46
    canvas.before:
        PushMatrix:
        Scale:
            origin: self.x + 0.5*self.width, self.y + 0.5*self.height
            x: self.scale
            y: self.scale

    canvas.after:
        PopMatrix:

<SmallChangeButton@HoverButton>:
    markup: True
    font_size: 16
    size_hint: None, None
    width:  self.texture_size[0] + 5
    height: self.texture_size[1] + 5 if self.texture_size[1] != 0 else 24
    background_color: 0, 0, 0, 1
    on_enter: self.setFontSize(20)
    on_leave: self.setFontSize(16)

<ChooseChangeScreen>:
    FloatLayout:
        Label:
            x: 20
            pos_hint: {"top": 1}
            font_size: 40
            size_hint: None, None
            width:  self.texture_size[0] + 5
            font_name: "TitleFont"
            text: "JARVIS"
        Label:
            font_size: 16
            pos_hint: {"top": 1, "right": .98}
            size_hint: None, None
            width:  self.texture_size[0] + 5
            height: self.texture_size[1] + 50
            color: utils.get_color_from_hex('#05eeff')
            markup: True
            text: "[b]Xari[/b]"
        BoxLayout:
            x: 20
            pos_hint: { "top": .5}
            size_hint_x: .5
            size_hint_y: None
            orientation: "vertical"
            spacing: 3
            ChangeButton:
                text: "[i][b]ADD CHANGES[/i][/b]"
                on_press:
                    root.manager.transition.direction = "right"
                    root.manager.transition.duration = .5
                    root.manager.current = 'MainMenu'
            ChangeButton:
                text: "[b][i]MODIFY CHANGES[/i][/b]"
            SmallChangeButton:
            SmallChangeButton:
                """)

动画是

def on_enter(self, *args):
    self.initial_font = self.font_size
    anim = Animation(font_size=self.font_size * 1.2, duration=.07)
    anim.start(self)

def on_leave(self, *args):
    anim = Animation(font_size=self.initial_font, duration=.07)
    anim.start(self)

0 个答案:

没有答案