Skip to content

Instantly share code, notes, and snippets.

@tshirtman
Last active April 26, 2020 22:51
Show Gist options
  • Save tshirtman/5651140 to your computer and use it in GitHub Desktop.
Save tshirtman/5651140 to your computer and use it in GitHub Desktop.
TextShadow example
from kivy.app import App
from kivy.uix.label import Label
from kivy.properties import ListProperty
class ShadowLabel(Label):
decal = ListProperty([0, 0])
tint = ListProperty([1, 1, 1, 1])
class ShadowApp(App):
pass
if __name__ == '__main__':
ShadowApp().run()
BoxLayout:
orientation: 'vertical'
ShadowLabel:
text: 'test ' * 10
decal: 10, -10
tint: .5, .5, .5, .5
color: 1, 1, 0, 1
ShadowLabel:
text: 'test test'
decal: 5, -5
tint: .1, .5, .5, .5
color: 1, 0, 1, 1
Widget:
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
ShadowLabel:
text: 'test'
decal: 2, -2
tint: .5, .5, 1, .5
color: 1, 0, 0, 1
pos: self.parent.pos
size: self.parent.size
<ShadowLabel>:
canvas.before:
Color:
rgba: root.tint
Rectangle:
pos:
int(self.center_x - self.texture_size[0] / 2.) + root.decal[0],\
int(self.center_y - self.texture_size[1] / 2.) + root.decal[1]
size: root.texture_size
texture: root.texture
Color:
rgba: 1, 1, 1, 1
@Allamaris0
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment