本文整理汇总了Python中kivy.graphics.transformation.Matrix.view_clip方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.view_clip方法的具体用法?Python Matrix.view_clip怎么用?Python Matrix.view_clip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.graphics.transformation.Matrix
的用法示例。
在下文中一共展示了Matrix.view_clip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_viewport
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import view_clip [as 别名]
def update_viewport(self):
from kivy.graphics.opengl import glViewport
from kivy.graphics.transformation import Matrix
from math import radians
w, h = self.system_size
w2, h2 = w / 2., h / 2.
r = radians(self.rotation)
# prepare the viewport
glViewport(0, 0, w, h)
# do projection matrix
projection_mat = Matrix()
projection_mat.view_clip(0.0, w, 0.0, h, -1.0, 1.0, 0)
self.render_context['projection_mat'] = projection_mat
# do modelview matrix
modelview_mat = Matrix().translate(w2, h2, 0)
modelview_mat = modelview_mat.multiply(Matrix().rotate(r, 0, 0, 1))
w, h = self.size
w2, h2 = w / 2., h / 2.
modelview_mat = modelview_mat.multiply(Matrix().translate(-w2, -h2, 0))
self.render_context['modelview_mat'] = modelview_mat
# redraw canvas
self.canvas.ask_update()
# and update childs
self.update_childsize()
示例2: update_viewport
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import view_clip [as 别名]
def update_viewport(self):
from kivy.graphics.opengl import glViewport
from kivy.graphics.transformation import Matrix
width, height = self.system_size
w2 = width / 2.
h2 = height / 2.
# prepare the viewport
glViewport(0, 0, width, height)
projection_mat = Matrix()
projection_mat.view_clip(0.0, width, 0.0, height, -1.0, 1.0, 0)
self.render_context['projection_mat'] = projection_mat
# use the rotated size.
# XXX FIXME fix rotation
'''
width, height = self.size
w2 = width / 2.
h2 = height / 2.
glTranslatef(-w2, -h2, -500)
# set the model view
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glTranslatef(w2, h2, 0)
glRotatef(self._rotation, 0, 0, 1)
glTranslatef(-w2, -h2, 0)
'''
self.update_childsize()
示例3: update_viewport
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import view_clip [as 别名]
def update_viewport(self):
from kivy.graphics.opengl import glViewport
from kivy.graphics.transformation import Matrix
from math import radians
w, h = self.system_size
if self._density != 1:
w, h = self.size
smode = self.softinput_mode
target = self._system_keyboard.target
targettop = target.to_window(0, target.y)[1] if target else 0
kheight = self.keyboard_height
w2, h2 = w / 2., h / 2.
r = radians(self.rotation)
x, y = 0, 0
_h = h
if smode == 'pan':
y = kheight
elif smode == 'below_target':
y = 0 if kheight < targettop else (kheight - targettop) + dp(9)
if smode == 'scale':
_h -= kheight
# prepare the viewport
glViewport(x, y, w, _h)
# do projection matrix
projection_mat = Matrix()
projection_mat.view_clip(0.0, w, 0.0, h, -1.0, 1.0, 0)
self.render_context['projection_mat'] = projection_mat
# do modelview matrix
modelview_mat = Matrix().translate(w2, h2, 0)
modelview_mat = modelview_mat.multiply(Matrix().rotate(r, 0, 0, 1))
w, h = self.size
w2, h2 = w / 2., h / 2.
modelview_mat = modelview_mat.multiply(Matrix().translate(-w2, -h2, 0))
self.render_context['modelview_mat'] = modelview_mat
# redraw canvas
self.canvas.ask_update()
# and update childs
self.update_childsize()
示例4: update_viewport
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import view_clip [as 别名]
def update_viewport(self):
from kivy.graphics.opengl import glViewport
from kivy.graphics.transformation import Matrix
from math import radians
w, h = self.system_size
if self._density != 1:
w, h = self.size
smode = self.softinput_mode
kheight = self.keyboard_height
w2, h2 = w / 2.0, h / 2.0
r = radians(self.rotation)
x, y = 0, 0
_h = h
if smode:
y = kheight
if smode == "scale":
_h -= kheight
# prepare the viewport
glViewport(x, y, w, _h)
# do projection matrix
projection_mat = Matrix()
projection_mat.view_clip(0.0, w, 0.0, h, -1.0, 1.0, 0)
self.render_context["projection_mat"] = projection_mat
# do modelview matrix
modelview_mat = Matrix().translate(w2, h2, 0)
modelview_mat = modelview_mat.multiply(Matrix().rotate(r, 0, 0, 1))
w, h = self.size
w2, h2 = w / 2.0, h / 2.0
modelview_mat = modelview_mat.multiply(Matrix().translate(-w2, -h2, 0))
self.render_context["modelview_mat"] = modelview_mat
# redraw canvas
self.canvas.ask_update()
# and update childs
self.update_childsize()
示例5: update_glsl
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import view_clip [as 别名]
def update_glsl(self, *largs):
asp = self.width / float(self.height)
asp = asp*0.3
proj = Matrix()
mat = Matrix()
mat = mat.look_at(0, 0, self.camera_translate[2], 0, 0, -3, 0, 1, 0)
proj = proj.view_clip(-asp, asp, -.3, .3, 1, 100, 1)
self.canvas['projection_mat'] = proj
self.canvas['modelview_mat'] = mat
示例6: update_glsl
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import view_clip [as 别名]
def update_glsl(self, *largs):
asp = self.width / float(self.height)
asp = 15 / 6.0
proj = Matrix()
mat = Matrix()
mat = mat.look_at(
self.camera_loc[0] * self.camera_r,
self.camera_loc[1] * self.camera_r,
self.camera_loc[2] * self.camera_r,
0,
0,
0,
self.camera_up[0],
self.camera_up[1],
self.camera_up[2],
)
proj = proj.view_clip(-asp * 0.5, asp * 0.5, -0.5, 0.5, 1, 10, 1)
self.canvas["projection_mat"] = proj
self.canvas["modelview_mat"] = mat