Group of Instructions. Allows for the adding and
removing of graphics instructions. It can be used directly as follows:

blue=InstructionGroup()blue.add(Color(0,0,1,0.2))blue.add(Rectangle(pos=self.pos,size=(100,100)))green=InstructionGroup()green.add(Color(0,1,0,0.4))green.add(Rectangle(pos=(100,100),size=(100,100)))# Here, self should be a Widget or subclass[self.canvas.add(group)forgroupin[blue,green]]

The ContextInstruction class is the base for the creation of instructions
that don’t have a direct visual representation, but instead modify the
current Canvas’ state, e.g. texture binding, setting color parameters,
matrix manipulation and so on.

This property represents the texture coordinates used for drawing the
vertex instruction. The value must be a list of 8 values.

A texture coordinate has a position (u, v), and a size (w, h). The size
can be negative, and would represent the ‘flipped’ texture. By default,
the tex_coords are:

[u,v,u+w,v,u+w,v+h,u,v+h]

You can pass your own texture coordinates if you want to achieve fancy
effects.

Warning

The default values just mentioned can be negative. Depending
on the image and label providers, the coordinates are flipped
vertically because of the order in which the image is internally
stored. Instead of flipping the image data, we are just flipping
the texture coordinates to be faster.

The opacity attribute controls the opacity of the canvas and its
children. Be careful, it’s a cumulative attribute: the value is
multiplied to the current global opacity and the result is applied to
the current context color.

For example: if your parent has an opacity of 0.5 and a child has an
opacity of 0.2, the real opacity of the child will be 0.5 * 0.2 = 0.1.

Note that if you perform many and/or costly calls to callbacks, you
might potentially slow down the rendering performance significantly.

The updating of your canvas does not occur until something new happens.
From your callback, you can ask for an update:

withself.canvas:self.cb=Callback(self.my_callback)# then later in the codeself.cb.ask_update()

If you use the Callback class to call rendering methods of another
toolkit, you will have issues with the OpenGL context. The OpenGL state may
have been manipulated by the other toolkit, and as soon as program flow
returns to Kivy, it will just break. You can have glitches, crashes, black
holes might occur, etc.
To avoid that, you can activate the reset_context option. It will
reset the OpenGL context state to make Kivy’s rendering correct after the
call to your callback.

Warning

The reset_context is not a full OpenGL reset. If you have issues
regarding that, please contact us.