Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_width(string, font=None):
t = Text(string)
if font:
t.font = font
w = t.width
from ursina import destroy
destroy(t)
return w
self.text_nodes = list()
self.images = list()
self.origin = (-.5, .5)
self.font = Text.default_font
self.resolution = Text.default_resolution
self.line_height = 1
self.use_tags = True
self.start_tag = start_tag
self.end_tag = end_tag
self.text_colors = {'default' : color.text_color}
for color_name in color.color_names:
self.text_colors[color_name] = color.colors[color_name]
self.tag = Text.start_tag+'default'+Text.end_tag
self.current_color = self.text_colors['default']
self.scale_override = 1
self._background = None
self.appear_sequence = None # gets created when calling appear()
if text != '':
self.text = text
for key, value in kwargs.items():
setattr(self, key, value)
def __init__(self, text='', start_tag=start_tag, end_tag=end_tag, ignore=True, **kwargs):
super().__init__(ignore=ignore)
self.size = Text.size
self.parent = camera.ui
self.setColorScaleOff()
self.text_nodes = list()
self.images = list()
self.origin = (-.5, .5)
self.font = Text.default_font
self.resolution = Text.default_resolution
self.line_height = 1
self.use_tags = True
self.start_tag = start_tag
self.end_tag = end_tag
self.text_colors = {'default' : color.text_color}
for color_name in color.color_names:
def print_on_screen(text, position=window.top_left, origin=(-.5,.5), scale=1, duration=1):
text_entity = Text(text=text, position=position, origin=origin, scale=scale)
destroy(text_entity, delay=duration)
def __init__(self, text='', start_tag=start_tag, end_tag=end_tag, ignore=True, **kwargs):
super().__init__(ignore=ignore)
self.size = Text.size
self.parent = camera.ui
self.setColorScaleOff()
self.text_nodes = list()
self.images = list()
self.origin = (-.5, .5)
self.font = Text.default_font
self.resolution = Text.default_resolution
self.line_height = 1
self.use_tags = True
self.start_tag = start_tag
self.end_tag = end_tag
self.text_colors = {'default' : color.text_color}
for color_name in color.color_names:
self.text_colors[color_name] = color.colors[color_name]
self.tag = Text.start_tag+'default'+Text.end_tag
self.current_color = self.text_colors['default']
self.scale_override = 1
self._background = None
self.appear_sequence = None # gets created when calling appear()
if text != '':
if __name__ == '__main__':
app = Ursina()
# Text.size = .001
descr = dedent('''
Rainstorm
Summon a rain storm to deal 5 water
damage to everyone, test including yourself.
Lasts for 4 rounds.''').strip()
# Text.default_font = 'VeraMono.ttf'
# Text.default_font = 'consola.ttf'
# color.text_color = color.lime
Text.default_resolution = 1080 * Text.size
test = Text(origin=(.5,.5), text=descr)
# test = Text(descr)
# test.text = ''
# print(test.images)
# print('\n', test.text, '\n\n')
# test.font = 'VeraMono.ttf'
# Text.font = 'VeraMono.ttf'
# test.origin = (.5, .5)
# test.origin = (0, 0)
# test.wordwrap = 40
text = Text(text=descr, wordwrap=10, y=.25, background=True)
def input(key):
if key == 'a':
test.appear(speed=.025)
# Text.default_font = 'consola.ttf'
# color.text_color = color.lime
Text.default_resolution = 1080 * Text.size
test = Text(origin=(.5,.5), text=descr)
# test = Text(descr)
# test.text = ''
# print(test.images)
# print('\n', test.text, '\n\n')
# test.font = 'VeraMono.ttf'
# Text.font = 'VeraMono.ttf'
# test.origin = (.5, .5)
# test.origin = (0, 0)
# test.wordwrap = 40
text = Text(text=descr, wordwrap=10, y=.25, background=True)
def input(key):
if key == 'a':
test.appear(speed=.025)
test.create_background()
print('....', Text.get_width('yolo'))
app.run()
# print('\n', test.text, '\n\n')
# test.font = 'VeraMono.ttf'
# Text.font = 'VeraMono.ttf'
# test.origin = (.5, .5)
# test.origin = (0, 0)
# test.wordwrap = 40
text = Text(text=descr, wordwrap=10, y=.25, background=True)
def input(key):
if key == 'a':
test.appear(speed=.025)
test.create_background()
print('....', Text.get_width('yolo'))
app.run()