Book Image

Kivy - Interactive Applications and Games in Python

By : Roberto Ulloa
Book Image

Kivy - Interactive Applications and Games in Python

By: Roberto Ulloa

Overview of this book

Table of Contents (13 chapters)
Kivy – Interactive Applications and Games in Python Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding images, colors, and backgrounds


In this section, we will discuss how to add images and colors to our graphics and how to control which graphic comes on top of which one. We continue using the same Python code of the first section. This time, we run it with a 400 x 100 screen size: python drawing.py --size=400x100. The following screenshot shows the final result of this section:

Images and Colors

The following is the corresponding drawing.kv code:

64. # File name: drawing.kv (Images and colors)
65. <DrawingSpace>:
66.     canvas:
67.         Ellipse:
68.            pos: 10,10
69.            size: 80,80
70.            source: 'kivy.png'
71.         Rectangle:
72.            pos: 110,10
73.            size: 80,80
74.            source: 'kivy.png'
75.        Color: 
76.            rgba: 0,0,1,.75
77.        Line:
78.            points: 10,10,390,10
79.            width: 10
80.            cap: 'square'
81.          Color: 
82.            rgba: 0,1,0,1
83.        Rectangle:
84.     ...