当前位置: 首页>>代码示例>>Python>>正文


Python Surface.resize方法代码示例

本文整理汇总了Python中surface.Surface.resize方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.resize方法的具体用法?Python Surface.resize怎么用?Python Surface.resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在surface.Surface的用法示例。


在下文中一共展示了Surface.resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: resize

# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import resize [as 别名]
 def resize(self, width, height):
     Surface.resize(self, width, height)
     self.surface.resize(width, height)
     try:
         self.surface._display.textbox.resize()
     except (TypeError, AttributeError):     #pyjs-O:TypeError/-S:AttributeError
         pass
     try:
         self.surface._display.textarea.resize()
     except (TypeError, AttributeError):     #pyjs-O:TypeError/-S:AttributeError
         pass
开发者ID:Lucytheanimefan,项目名称:Center-for-Advanced-HindSight-Games,代码行数:13,代码来源:display.py

示例2: Canvas

# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import resize [as 别名]
class Canvas(Surface, MouseWheelHandler):

    def __init__(self, size, buffered):
        Surface.__init__(self, size)
        MouseWheelHandler.__init__(self, True)
        if isinstance(buffered, bool):
            self._bufferedimage = buffered
        else:
            self._bufferedimage = True
        try:
            if self.impl.canvasContext:
                self._isCanvas = True
        except:
            self._isCanvas = False
            self._bufferedimage = False
        if self._bufferedimage:
            self.surface = Surface(size)
        else:
            self.surface = self
        self.resize(size[0], size[1])
        self.images = {}
        self.image_list = []
        self.function = None
        self.time_wait = 0
        self.time = Time()
        self.event = pyjsdl.event
        self.addMouseListener(self)
        self.addMouseWheelListener(self)
        self.addKeyboardListener(self)
        self.sinkEvents(Event.ONMOUSEDOWN | Event.ONMOUSEUP| Event.ONMOUSEMOVE | Event.ONMOUSEOUT | Event.ONMOUSEWHEEL | Event.ONKEYDOWN | Event.ONKEYPRESS | Event.ONKEYUP)
        self.modKey = pyjsdl.event.modKey
        self.specialKey = pyjsdl.event.specialKey
        self._rect_list = []
        self._rect_list.append(Rect(0,0,0,0))
        self._rect_len = 1
        self._rect_num = 0
        self._rect_temp = Rect(0,0,0,0)
        _animationFrame = self._initAnimationFrame()
        if _animationFrame:
            self.time_hold_min = 0
        else:
            self.time_hold_min = 1
        self.time_hold = self.time_hold_min

    def _initAnimationFrame(self):
        JS("""
            $wnd['requestAnimationFrame'] = $wnd['requestAnimationFrame'] ||
                                            $wnd['mozRequestAnimationFrame'] ||
                                            $wnd['webkitRequestAnimationFrame'] ||
                                            $wnd['oRequestAnimationFrame'];
           """)
        if JS("""$wnd['requestAnimationFrame'] != undefined"""):
            _animationFrame = True
        else:
            JS("""$wnd['requestAnimationFrame'] = function(cb){cb()};""")
            _animationFrame = False
        return _animationFrame

    def onMouseMove(self, sender, x, y):
        event = DOM.eventGetCurrentEvent()
        event.pos = (x, y)
        self.event.mouseMove['x'], self.event.mouseMove['y'] = x, y
        self.event._updateQueue(event)

    def onMouseDown(self, sender, x, y):
        event = DOM.eventGetCurrentEvent()
        event.pos = (x, y)
        self.event.mousePress[event.button] = True
        self.event._updateQueue(event)

    def onMouseUp(self, sender, x, y):
        event = DOM.eventGetCurrentEvent()
        event.pos = (x, y)
        self.event.mousePress[event.button] = False
        self.event._updateQueue(event)

    def onMouseLeave(self, sender):
        self.event.mousePress[0], self.event.mousePress[1], self.event.mousePress[2] = False, False, False
        self.event.mouseMove['x'], self.event.mouseMove['y'] = -1, -1
        self.event.mouseMoveRel['x'], self.event.mouseMoveRel['y'] = None, None
        for keycode in self.modKey:
            if self.event.keyPress[keycode]:
                self.event.keyPress[keycode] = False

    def onMouseWheel(self, sender, velocity):
        event = DOM.eventGetCurrentEvent()
        if event.type == 'mousewheel':
            #TODO: update for changes in mousewheel implementation
            if hasattr(event, 'wheelDeltaX'):
                self.onMouseWheel = self._onMouseWheel
                self._onMouseWheel(sender, velocity)
            else:
                self.onMouseWheel = self._onMouseWheelY
                DOM.eventGetMouseWheelVelocityY = eventGetMouseWheelVelocityY
                self._onMouseWheelY(sender, eventGetMouseWheelVelocityY(event))
        else:       #DOMMouseScroll
            self.onMouseWheel = self._onMouseScroll
            self._onMouseScroll(sender, velocity)

    def _onMouseWheel(self, sender, velocity):
#.........这里部分代码省略.........
开发者ID:Lucytheanimefan,项目名称:Center-for-Advanced-HindSight-Games,代码行数:103,代码来源:display.py


注:本文中的surface.Surface.resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。