Table Of Contents
Scissor Instructions¶
バージョン 1.9.1 で追加.
Scissor instructions clip your drawing area into a rectangular region.
ScissorPush
: Begins clipping, sets the bounds of the clip spaceScissorPop
: Ends clipping
The area provided to clip is in screenspace pixels and must be provided as integer values not floats.
The following code will draw a circle ontop of our widget while clipping the circle so it does not expand beyond the widget borders.
with self.canvas.after:
#If our widget is inside another widget that modified the coordinates
#spacing (such as ScrollView) we will want to convert to Window coords
x,y = self.to_window(*self.pos)
width, height = self.size
#We must convert from the possible float values provided by kivy
#widgets to an integer screenspace, in python3 round returns an int so
#the int cast will be unnecessary.
ScissorPush(x=int(round(x)), y=int(round(y)),
width=int(round(width)), height=int(round(height)))
Color(rgba=(1., 0., 0., .5))
Ellipse(size=(width*2., height*2.),
pos=self.center)
ScissorPop()
-
class
kivy.graphics.scissor_instructions.
Rect
¶ ベースクラス:
builtins.object
Rect class used internally by ScissorStack and ScissorPush to determine correct clipping area.
-
class
kivy.graphics.scissor_instructions.
ScissorPop
¶ ベースクラス:
kivy.graphics.instructions.Instruction
Pop the scissor stack. Call after ScissorPush, once you have completed the drawing you wish to be clipped.
-
class
kivy.graphics.scissor_instructions.
ScissorPush
¶ ベースクラス:
kivy.graphics.instructions.Instruction
Push the scissor stack. Provide kwargs of ‘x’, ‘y’, ‘width’, ‘height’ to control the area and position of the scissoring region. Defaults to 0, 0, 100, 100
Scissor works by clipping all drawing outside of a rectangle starting at int x, int y position and having sides of int width by int height in Window space coordinates
-
class
kivy.graphics.scissor_instructions.
ScissorStack
¶ ベースクラス:
builtins.object
Class used internally to keep track of the current state of glScissors regions. Do not instantiate, prefer to inspect the module’s scissor_stack.