【问题标题】:Is there a way to flip a label in kivy horizontally?有没有办法水平翻转kivy中的标签?
【发布时间】:2021-06-06 08:27:02
【问题描述】:

所以就像你从镜子里看它一样。例如,不能只做texture_size(-100,50),会保持直线

【问题讨论】:

    标签: python user-interface kivy


    【解决方案1】:

    实现此目的的一种半hacky方法是将其垂直翻转,然后旋转图像以获得与水平翻转相同的效果

    python 文件:

    class MirrorCamera(Camera):
        def _camera_loaded(self, *largs):
            self.texture = self._camera.texture            
            self.texture_size = list(self.texture.size)
            self.texture.flip_vertical()
    

    kivy 文件:

    <MirrorCamera>
        canvas.before:
            PushMatrix
            Translate:
                xy: (self.x + self.width / 2, self.y + self.height / 2)
            Rotate:
                angle: 180
                axis: (0, 0, 1.0)
            Translate:
                xy: (-self.x - self.width / 2, -self.y - self.height / 2)
        canvas.after:
            PopMatrix
    

    【讨论】:

    • 这太奇怪了。所以这就像先把它做成 3d,然后从相机上看?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-14
    • 2022-08-14
    • 1970-01-01
    • 1970-01-01
    • 2015-07-06
    相关资源
    最近更新 更多