【发布时间】:2024-06-20 14:10:02
【问题描述】:
我认为这可能是对 kivy 中更深层次的东西的简单理解,但我有一个 RoundedImage 类,它生成两个图像,其中一个是没有圆角的原始图像,另一个是屏幕外的圆角。怎么回事?
截图: http://imgur.com/gallery/IRYfr
我认为这可能与子类化 Image 有关?
class RoundedImage(Image,StyleUnit):
_styleist = RadialGradientStyleist
_radius = [20]
_source = ''
_style = None
def __init__(self,**kwargs):
super(RoundedImage,self).__init__(**kwargs)
#self._source = source
#self.initalizeStyle()
with self.canvas:
StencilPush()
self.m_rect = RoundedRectangle( size = self.norm_image_size , \
pos=self.center, \
radius=self._radius)
StencilUse()
self.rect = Rectangle( size = self.norm_image_size , \
pos = self.center, \
texture = self.texture)
StencilUnUse()
StencilPop()
#Color(1,1,1)
#self.line = Line( rounded_rectangle=self.pos+self.size+self._radius,
# width=10)
self.bind(pos = self.update_rect,
size = self.update_rect)
def update_rect(self,*args):
self.m_rect.pos = self.center
self.m_rect.size = self.norm_image_size
self.rect.pos = self.center
self.rect.size = self.norm_image_size
应用代码很简单:
class ProfilesApp(App):
def build(self):
profile = RoundedImage( source = source,#self.imageLocation,\
allow_stretch=True)
return profile
profileApp = ProfilesApp()
profileApp.run()
【问题讨论】:
-
你想做什么?
标签: python image canvas graphics kivy