Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Kivy Cookbook

You're reading from   Kivy Cookbook Enhance your skills in developing multi-touch applications with Kivy

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781783987382
Length 246 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Hugo Solis Hugo Solis
Author Profile Icon Hugo Solis
Hugo Solis
 Solis Solis
Author Profile Icon Solis
Solis
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Kivy Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Kivy and the Kv Language FREE CHAPTER 2. Input, Motion, and Touch 3. Events 4. Widgets 5. Graphics – Canvas and Instructions 6. Advanced Graphics – Shaders and Rendering 7. The API in Detail 8. Packaging our Apps for PC 9. Kivy for Mobile Devices Index

Storing and retrieving the coordinate space context


The graphical environment in Kivy uses a coordinate space to locate the content. In this recipe, we will take a look at how to work with the coordinate space. This recipe will define a vector and make some basic operations with it.

Getting ready

Now we are going to use the mathematical concept of vectors. You will get a better understanding of this recipe if you have the concept clear. Read the Wikipedia about it, a good start point. The implementation is made on top of a Python list, so it is important to have a good understanding of that concept too.

How to do it…

In this recipe, we will work directly with Python to show the possibilities of the vectors in Kivy, for which we will use the common vector operations.

  1. First, let's define a vector:

    v = Vector(82, 34)
    
  2. Now if we want to retrieve the coordinate from a widget, we use:

    w = widget.pos
    
  3. The sum of the last two defined vectors is given by:

    x = v + w
    
  4. The product of those vectors is given...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images