canvas = Canvas(is_broadcasting=False) t = Text( text='Hello\nworld!', font_size=100, color=GOLD, font_name=PATH.joinpath('Xolonium-Regular.ttf').as_posix(), ) t.pos = ( Window.width / 2 - t.width / 2, Window.height / 2 - t.height / 2, ) canvas.add(t) yari.add_node(canvas) @kb.listen('on_key_down') def key_down(node, *args): if kb.is_key_down('1'): t.text = 'Hello' if kb.is_key_down('2'): t.text += '\nworld!' if kb.is_key_down('3'): t.text = '' if kb.is_key_down('='): t.alpha += .25 if kb.is_key_down('-'): t.alpha -= .25 if kb.is_key_down('up'):
from yari import yari from yari.ui import Label yari.add_node(Label(text='Hello world!')) if __name__ == '__main__': yari.run()
) # Rectangle.texture PATH = Path(__file__).absolute().parent sprite_map = Atlas(PATH.joinpath('player.atlas').as_posix()) rect2 = Rectangle( texture=sprite_map['walk_1'], pos=(200, 0), ) # Compose the images into the node node.canvas.add(rect) node.canvas.add(rect2) node.add_node(img) yari.add_node(node) class AnimCounter: time = 0. _rate = 5 tick = 1 / _rate frame = 1 src = 'atlas://player/walk_{}' src2 = 'walk_{}' @property def rate(self): return self._rate @rate.setter
yari.mainloop.delay = 1 / 30 yari.config.set('graphics', 'target_fps', 30) yari.config.set('kivy', 'log_level', 'debug') # Initialize nodes label = Label( text='Hello world!', background_color=(1, .75, .23, 1), color=(0, 0, 0, 1), ) label.pos = ( yari.window.width / 2 - label.width / 2, yari.window.height / 2 - label.height / 2, ) # Compose nodes yari.add_node(label) # Mainloop @yari.mainloop.listen('on_timeout') def update(node, delta): label.angle += 100 * delta yari.log.debug(f'UPDATING ANGLE: {label.angle}') if __name__ == '__main__': yari.run()
from kivy.core.window import Window from yari import yari from yari.layouts import FloatLayout from yari.ui import Label # Initialize nodes label = Label( text='Hello world!', background_color=(.1, .2, .5, 1), angle=30, size_hint=(.2, .2), ) layout = FloatLayout( background_color=(.4, .3, .5, 1), size=Window.size, ) # Compose nodes layout.add_node(label) yari.add_node(layout) if __name__ == '__main__': yari.run()