Reputation: 1181
New to Kivy. Is there a way to crop a square image to a circle one with kivy when presenting it? Thanks!
Upvotes: 0
Views: 3662
Reputation: 841
You can use a canvas and set it to Elipse as follow:
from kivy.app import App
from kivy.lang import Builder
kv = '''
BoxLayout:
orientation: 'vertical'
FloatLayout:
canvas:
Color:
rgb: 1, 1, 1
Ellipse:
pos: 280, 200
size: 200 , 200
source: 'image.jpg'
angle_start: 0
angle_end: 360
'''
class App(App):
def build(self):
return Builder.load_string(kv)
App().run()
Upvotes: 2
Reputation: 1325
from kivy.lang import Builder
from kivymd.app import MDApp
KV = '''
MDScreen:
MDIconButton:
icon: "data/logo/kivy-icon-512.png"
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Upvotes: 0