Search code examples
kivykivy-language

In this code, how can I change the opacity of the red rectangle to see both the green and orange rectangles behind the red rectangle?


In this code, I'm using two rectangles inside a canvas. How can I change the opacity of the red rectangle to see both the green and orange rectangles behind the red rectangle?

Builder.load_string('''
  
 
<main>:
      
     
    RelativeLayout :
         
        size: root.width,root.height

         
        canvas:
        
            Color:
                rgb:196/255, 95/255, 49/255
            Rectangle:
                size:470,root.height
            Color:
                rgb:133/255, 22/255, 49/255
            Rectangle:
                size:470,100
                pos:[33, 33]                
''')

class main(Screen):
     pass
    
        
 
class test(App):
    def build(self):
       
        sm = sm = ScreenManager()
        sm.add_widget(main(name='main'))
        Window.clearcolor=(55/255, 77/255, 33/255)
        return sm 

if __name__=='__main__':
    test().run()

Solution

  • Just specify the opacity of the Rectangle, like this:

            Color:
                rgba:133/255, 22/255, 49/255, 0.75