Book Image

Kivy Cookbook

By : Hugo Solis
Book Image

Kivy Cookbook

By: Hugo Solis

Overview of this book

Table of Contents (16 chapters)
Kivy Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using drawing instructions


Let's start to create some new graphics. In a visual app, astonishing graphics are fundamentals. This recipe will create some basic geometric shapes.

Getting ready

This recipe uses the OpenGL philosophy about drawing; if you are not familiar with this, you have to keep in mind that the drawing of geometric shapes is based on the mathematical knowledge behind them. For example, the triangle needs three points to be drawn, but not any three points can draw a triangle.

How to do it…

In this recipe, in the KV file, we will be adding four drawing instructions to the root widget canvas, and we will have a simple Python file for our app. To complete the recipe, follow these steps:

  1. In the KV file, define the rule for the root widget.

  2. Define the canvas property for the root widget.

  3. Add the drawing instructions for an ellipse.

  4. Add the drawing instructions for a rectangle.

  5. Add the drawing instructions for a triangle.

  6. Add the drawing instructions for a line:

    <MyW>:
        canvas:...