本文整理汇总了Python中pyglet.window.Window.set_size方法的典型用法代码示例。如果您正苦于以下问题:Python Window.set_size方法的具体用法?Python Window.set_size怎么用?Python Window.set_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet.window.Window
的用法示例。
在下文中一共展示了Window.set_size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Camera_test
# 需要导入模块: from pyglet.window import Window [as 别名]
# 或者: from pyglet.window.Window import set_size [as 别名]
class Camera_test(MyTestCase):
def setUp(self):
self.window = Window(
width=200, height=100, visible=False, caption="Camera_test setup")
self.window.dispatch_events()
glClearColor(0, 0, 0, 1)
self.window.clear()
self.world = World()
self.camera = Camera((0, 0), 1)
def tearDown(self):
self.window.close()
def test_constructor(self):
camera = Camera((1, 2), 3, 4)
self.assertEquals(camera.x, 1, "should init x")
self.assertEquals(camera.y, 2, "should init y")
self.assertEquals(camera.scale, 3, "should init scale")
self.assertEquals(camera.angle, 4, "should init angle")
def test_constructor_defaults_angle(self):
camera = Camera((10, 20), 30)
self.assertEquals(camera.angle, 0.0, "should init angle")
def _draw_rect(self, backColor, polyColor, left, bottom, right, top):
glClearColor(
backColor[0]/255,
backColor[1]/255,
backColor[2]/255,
1.0)
self.window.clear()
verts = [
(left, bottom),
(right, bottom),
(right, top),
(left, top),
]
glColor3ub(*polyColor)
glBegin(GL_TRIANGLE_FAN)
for vert in verts:
glVertex2f(*vert)
glEnd()
def test_world_projection_default(self):
rect = (-0.2, -0.4, +0.6, +0.8)
expectedRect = (90, 10, 129, 69)
self.assert_world_projection(rect, expectedRect)
def test_defect_pyglet_get_color_buffer_for_resized_windows(self):
self.window.set_size(111, 222)
self.window.dispatch_events()
mgr = get_buffer_manager()
col_buf = mgr.get_color_buffer()
col_buf_size = col_buf.width, col_buf.height
self.assertEquals(col_buf_size, (111, 222), "pyglet bug regression")
def test_world_projection_strange_aspect(self):
# create a new window, since
# resizing the existing window doesn't work for some reason
# even if we dispatch events. Default handlers?
self.window.close()
self.window = Window(
width=100, height=200, visible=False,
caption="world.test_projection_strange_aspect")
self.window.dispatch_events()
rect = (-0.2, -0.4, +0.6, +0.8)
expectedRect = (40, 60, 79, 119)
self.assert_world_projection(rect, expectedRect)
def test_world_projection_offset(self):
self.camera.x, self.camera.y = (+0.5, +0.3)
rect = (-0.2, -0.4, +0.6, +0.8)
expectedRect = (65, 25, 104, 84)
self.assert_world_projection(rect, expectedRect)
def test_world_projection_scale(self):
self.camera.scale = 10
rect = (-1, -2, +3, +4)
expectedRect = (95, 30, 114, 59)
self.assert_world_projection(rect, expectedRect)
def test_world_projection_angle(self):
self.camera.angle = pi/2
rect = (-0.2, -0.4, +0.6, +0.8)
expectedRect = (60, 20, 119, 59)
self.assert_world_projection(rect, expectedRect)
#.........这里部分代码省略.........