Class GImage

The class provides support for drawing an image file. The image is given by a JPEG, PNG, or GIF file whose name is stored in the attribute source. Image files should be stored in the Images directory so that Kivy can find them without the complete path name.

This class acts much like is parent GRectangle and shares all of the same properties. As with that class, you can add a border to the rectangle if you want, using the attribute linewidth.

If the attributes width and height do not agree with the actual size of the image, the image is scaled to fit. Furthermore, if you define fillcolor, Kivy will tint your image by the given color.

If the image supports transparency, then this object can be used to represent irregular shapes. However, the contains method still treats this shape as a rectangle.

Constructor

GImage(**keywords)

Constructor: Creates a new rectangle image

To use the constructor for this class, you should provide it with a list of keyword arguments that initialize various attributes. The keywords are the same as the attribute names. For example, to load the image beach-ball.png, use the constructor

GImage(x=0,y=0,width=10,height=10,source=’beach-ball.png’)

This class supports the all same keywords as GRectangle; the only new keyword is source. See the documentation of GRectangle and GObject for the other supported keywords.

Parameter:keywords – dictionary of keyword arguments

Precondition: See above.

Attributes

This class has all of the attributes of GRectangle. In addition, it has the following new attributes.

source

The source file for this image.

Invariant. Must be a string refering to a valid file.