章节知识点总揽
在canvas中,可以使用Translate指令进行平移,除了属性外,使用Translate与Rotate指令基本一样,这里如果不用canvas.before属性就会出现前面两篇的问题
实例:设置平移坐标空间
在使用Translate指令时,需要指定在x轴、y轴和z轴上移动的距离;如果不指定,则默认不移动,修改rotate.kv文件,具体代码如下:
<MyImage@Image>:
source:'01.jpg'
pos:self.parent.pos
size_hint:.5,.4
canvas.before:
PushMatrix
Translate:
x:-100
y:200
z:0
Rotate:
axis:(0,0,1)
angle:60
origin:self.center
Color:
rgba:1,0,0,.5
Line:
rectangle:self.x,self.y,self.width,self.height
canvas.after:
PopMatrix
<RotateGridLayoutWidget>:
cols:2
canvas:
Color:
rgba:(1,1,1,1)
Rectangle:
pos:self.pos
size:self.size
Button:
text:'col:1,row;1'
FloatLayout:
MyImage:
Button:
text:'col:1,row:2'

博客介绍了在canvas中使用Translate指令进行平移的相关知识,指出使用Translate与Rotate指令基本类似,若不用canvas.before属性会出现问题。还给出设置平移坐标空间的实例,包括指定坐标轴移动距离、修改代码、使用图片等,提及前后篇分别是图像旋转和缩放坐标空间。
最低0.47元/天 解锁文章
5万+

被折叠的 条评论
为什么被折叠?



