目录
剪刀指令¶
在 1.9.1 版本加入.
剪刀指令会将您的绘图区域裁剪为一个矩形区域。
ScissorPush:开始裁剪,设置裁剪空间的边界ScissorPop:结束裁剪
提供给裁剪的区域以屏幕空间像素为单位,且必须为整数值,而非浮点数。
以下代码将在我们的控件顶部绘制一个圆形,同时裁剪该圆形,使其不会超出控件的边界。
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(int x, int y, int width, int height)¶
基类:
objectRect 类由 ScissorStack 和 ScissorPush 内部使用,用于确定正确的裁剪区域。
- intersect(self, Rect other)¶
- class kivy.graphics.scissor_instructions.ScissorPop¶
基类:
Instruction弹出剪刀堆栈。在调用ScissorPush之后,一旦完成了需要裁剪的绘制,即可调用此方法。
- class kivy.graphics.scissor_instructions.ScissorPush(**kwargs)¶
基类:
Instruction用于控制裁剪区域的面积和位置。默认值为0, 0, 100, 100。
Scissor 通过裁剪所有绘制在窗口空间坐标中起始于 int x、int y 位置,且边长为 int width 和 int height 的矩形之外的图形来工作。
- class kivy.graphics.scissor_instructions.ScissorStack¶
基类:
object用于内部跟踪glScissors区域当前状态的类。请勿实例化,建议检查模块的scissor_stack。
- pop(self)¶
- push(self, element)¶