Created
October 29, 2019 23:10
-
-
Save tshirtman/c5cc5880a3e4de901bf83bfd60d99e65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.lang import Builder | |
from kivy.factory import Factory | |
KV = ''' | |
#:import A kivy.animation.Animation | |
<AutoScaleLabel@Label>: | |
scale: 1 | |
step: self.font_size // 2 | |
interpolate: True | |
_params: divmod(self.scale, self.step or 1) | |
font_size: max(0, self._params[0] * (self.step or 1)) | |
_scale_factor: (1 + self._params[1] / (self.font_size or 1)) if self.interpolate else 1 | |
canvas.before: | |
PushMatrix: | |
Scale: | |
origin: self.center | |
xyz: self._scale_factor or 1, self._scale_factor or 1, 1 | |
canvas.after: | |
PopMatrix: | |
FloatLayout: | |
BoxLayout: | |
orientation: 'vertical' | |
AutoScaleLabel: | |
id: label | |
text: text.text | |
interpolate: interpolate.active | |
# scale: slider.value | |
GridLayout: | |
cols: 2 | |
size_hint_y: None | |
height: self.minimum_height | |
row_default_height: 30 | |
row_force_default: True | |
Label: | |
text: 'text' | |
TextInput: | |
id: text | |
text: 'test' | |
Label: | |
text: 'font_size' | |
Slider: | |
id: slider | |
min: .1 | |
max: 500 | |
on_value: | |
if animate.active: (A.cancel_all(label, 'scale'), A(scale=self.value, t=easing.text).start(label)) | |
else: label.scale = self.value | |
Label: | |
text: 'interpolate?' | |
CheckBox: | |
id: interpolate | |
Label: | |
text: 'animate?' | |
CheckBox: | |
id: animate | |
Label: | |
text: 'easing' | |
Spinner: | |
id: easing | |
text: 'linear' | |
values: 'linear', 'out_quad', 'out_elastic', 'out_circ' | |
''' | |
class Application(App): | |
def build(self): | |
return Builder.load_string(KV) | |
if __name__ == "__main__": | |
Application().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment