From 14694d68d28cd889ce97730ab06da427eac84a9e Mon Sep 17 00:00:00 2001 From: quadrismegistus Date: Thu, 13 Aug 2020 09:04:06 +0100 Subject: [PATCH] circularized profile image! --- client/screens/profile/profile.kv | 11 ++++++----- client/screens/profile/profile.py | 32 +++++++------------------------ 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/client/screens/profile/profile.kv b/client/screens/profile/profile.kv index 93d3785..368c390 100644 --- a/client/screens/profile/profile.kv +++ b/client/screens/profile/profile.kv @@ -20,16 +20,17 @@ size_hint:None,None # height:'200dp' # width:'300dp' - md_bg_color:1,1,0,1 + # md_bg_color:1,1,0,1 pos_hint: {'center_x':0.5,'center_y':0.88} - radius:[20,] - border_radius:20 + # radius:[20,] + # border_radius:20 canvas: Color: rgb: 0,0,0,1 Line: - width: 3 - rectangle: (self.x, self.y, self.width, self.height) + width: 2 + # rectangle: (self.x, self.y, self.width, self.height) + circle: (self.center_x, self.center_y, min(self.width, self.height) / 2) #(self.x, self.x, self.width) : cols:1 diff --git a/client/screens/profile/profile.py b/client/screens/profile/profile.py index 8e6e3d4..b5cf18c 100644 --- a/client/screens/profile/profile.py +++ b/client/screens/profile/profile.py @@ -12,9 +12,10 @@ from kivy.core.image import Image as CoreImage import io img_src = 'assets/avatar.jpg' #cache/img/1e6/587e880344d1e88cec8fda65b1148.jpeg' +# img_src = '/home/ryan/Pictures/Harrier.jpeg' cover_img_src='assets/cover.jpg' #cache/img/60d/9de00e52e4758ade5969c50dc053f.jpg' -class ProfileAvatar(CoreImage): pass +class ProfileAvatar(Image): pass class LayoutAvatar(MDBoxLayout): pass @@ -72,32 +73,13 @@ class ProfileScreen(BaseScreen): # get circular image circ_img = circularize_img(img_src,200) self.avatar_layout = LayoutAvatar() - self.avatar = ProfileAvatar(io.BytesIO(circ_img.read()),ext='png') - - - log(self.avatar.width) - log(self.avatar.norm_image_size) - - maxwidth=200 - maxheight=200 - - imgwidth = self.avatar.norm_image_size[0] - imgheight = self.avatar.norm_image_size[1] - - - if imgheight>imgwidth: - newheight=maxheight - newwidth = newheight * self.avatar.image_ratio - log('new!',newwidth,newheight) - else: - newwidth=maxwidth - newheight = newwidth / self.avatar.image_ratio - - self.avatar_layout.height=dp(newheight) - self.avatar_layout.width=dp(newwidth) + img = CoreImage(io.BytesIO(circ_img.read()),ext='png') + self.avatar = ProfileAvatar() + self.avatar.texture = img.texture + self.avatar_layout.height=dp(width) + self.avatar_layout.width=dp(width) self.avatar_layout.add_widget(self.avatar) - if do_cover_img: self.cover_image = CoverImage(source=cover_img_src) self.cover_layout = LayoutCover(source=cover_img_src)