title: Rounded corners with Kivy (using Python only)
body: <p>I have this little Kivy app (Python version: 3.7, Kivy version: 1.11.1):</p>
  
  <p><strong>Code#1</strong></p>
  
  <pre><code>from kivy.app import App
  from kivy.lang import Builder
  from kivy.config import Config
  from kivy.uix.floatlayout import FloatLayout
  
  Config.set("graphics", "width", "500")
  Config.set("graphics", "height", "300")
  
  kv = """
  &lt;RoundedCornerLayout@FloatLayout&gt;:
      background_color: 0,0,0,0
      canvas.before:
          Color:
              rgba: (.4,.4,.4,1)
          RoundedRectangle:
              pos: self.pos
              size: self.size
              radius: [(40, 40), (40, 40), (20, 20), (20, 20)]
  """
  
  Builder.load_string(kv)
  
  
  class RoundedCornerLayout(FloatLayout):
      def __init__(self):
          super().__init__()
          self.size_hint = (None, None)
          self.size = (400, 200)
          self.pos_hint = {"center_x": 0.5, "center_y": 0.5}
  
  
  class MainApp(App):
      def build(self):
          return RoundedCornerLayout()
  
  
  if __name__ == "__main__":
      MainApp().run()
  </code></pre>
  
  <p>And with that code, I have the following result:</p>
  
  <p><a href="https://i.stack.imgur.com/z0ZaB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z0ZaB.png" alt="enter image description here"></a></p>
  
  <p>Cute, isn't it?</p>
  
  <p>Now, let's try to get the same result using only Python. I'm trying with the following code:</p>
  
  <p><strong>Code#2</strong></p>
  
  <pre><code>from kivy.app import App
  from kivy.config import Config
  from kivy.graphics import Color
  from kivy.graphics import Rectangle
  from kivy.uix.floatlayout import FloatLayout
  
  Config.set("graphics", "width", "500")
  Config.set("graphics", "height", "300")
  
  
  class RoundedCornerLayout(FloatLayout):
      def __init__(self):
          super().__init__()
          self.size_hint = (None, None)
          self.size = (400, 200)
          self.pos_hint = {"center_x": 0.5, "center_y": 0.5}
  
          self.background_color = (0, 0, 0, 0)
          self.canvas.before.add(Color(.4, .4, .4, 1))
          self.canvas.before.add(Rectangle(
              pos=self.pos,
              size=self.size,
              radius=[(40, 40), (40, 40), (20, 20), (20, 20)]))
  
  
  class MainApp(App):
      def build(self):
          return RoundedCornerLayout()
  
  
  if __name__ == "__main__":
      MainApp().run()
  </code></pre>
  
  <p>Fair enough, I thought.</p>
  
  <p>But then I got this result:</p>
  
  <p><a href="https://i.stack.imgur.com/jUCiz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jUCiz.png" alt="enter image description here"></a></p>
  
  <p>As far as my knowledge goes, both instructions (Code#1 and Code#2) are saying the same, but in different ways. Scientifically proven, it's not like that.</p>
  
  <p>...So what I'm trying to understand here, and the point of my question, is: what's the functional difference between Code#1 and Code#2? Why are they displaying different results? And what would be the correct way to "translate" Code#1 into Python-only code?</p>
  
  <p>Ignore the fact that just keeping the kivy code is the easiest solution. What I need here is to understand this behaviour, explaining my reasons would unnecessarily extend this question, let's just say you can only control what you understand.</p>