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


Python graphics.Batch方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self):
        # A Batch is a collection of vertex lists for batched rendering.
        self.batch = Batch()
        # A TextureGroup manages an OpenGL texture.
        self.texture_group = {}
        # Mapping from position to a pyglet `VertextList` for all shown blocks.
        self._shown = {}
        self.show_hide_queue = OrderedDict()
        # Which sector the player is currently in.
        self.sector = None

        # Mapping from sector to a list of positions inside that sector.
        self.sectors = {}
        # Same mapping as `world` but only contains blocks that are shown.
        self.shown = {}

        self.shader = None
        PycraftOpenGL()

        self.init_shader()

        # A mapping from position to the texture of the block at that position.
        # This defines all the blocks that are currently in the world.
        self.area = Area() 
开发者ID:traverseda,项目名称:pycraft,代码行数:26,代码来源:world.py

示例2: text_window

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def text_window(request):
    class _TestWindow(window.Window):
        def __init__(self, doctype, *args, **kwargs):
            super(_TestWindow, self).__init__(*args, **kwargs)

            self.batch = graphics.Batch()
            self.document = doctype()
            self.layout = layout.IncrementalTextLayout(self.document,
                self.width, self.height, batch=self.batch)

        def on_draw(self):
            gl.glClearColor(1, 1, 1, 1)
            self.clear()
            self.batch.draw()

        def set_bold(self):
            self.document.set_style(0, len(self.document.text), {"bold": True})

    return _TestWindow(request.param) 
开发者ID:pyglet,项目名称:pyglet,代码行数:21,代码来源:test_empty_document.py

示例3: __init__

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, multiline, wrap_lines, msg, *args, **kwargs):
        super(TestWindow, self).__init__(*args, **kwargs)

        self.batch = graphics.Batch()
        self.document = text.decode_attributed(msg)
        self.margin = 2
        self.layout = layout.IncrementalTextLayout(self.document,
            (self.width - self.margin * 2),
            self.height - self.margin * 2,
            multiline=multiline,
            wrap_lines=wrap_lines,
            batch=self.batch)
        self.caret = caret.Caret(self.layout)
        self.push_handlers(self.caret)

        self.wrap_lines = wrap_lines

        self.set_mouse_cursor(self.get_system_mouse_cursor('text')) 
开发者ID:pyglet,项目名称:pyglet,代码行数:20,代码来源:test_multiline_wrap.py

示例4: __init__

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, vertex_lists, groups, batch):
        """Create a model.

        :Parameters:
            `vertex_lists` : list
                A list of `~pyglet.graphics.VertexList` or
                `~pyglet.graphics.IndexedVertexList`.
            `groups` : list
                A list of `~pyglet.model.TexturedMaterialGroup`, or
                 `~pyglet.model.MaterialGroup`. Each group corresponds to
                 a vertex list in `vertex_lists` of the same index.
            `batch` : `~pyglet.graphics.Batch`
                Optional batch to add the model to. If no batch is provided,
                the model will maintain it's own internal batch.
        """
        self.vertex_lists = vertex_lists
        self.groups = groups
        self._batch = batch
        self._rotation = 0, 0, 0
        self._translation = 0, 0, 0 
开发者ID:pyglet,项目名称:pyglet,代码行数:22,代码来源:__init__.py

示例5: __init__

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, *args, **kwargs):
        super(TestWindow, self).__init__(*args, **kwargs)

        self.batch = graphics.Batch()
        self.document = text.decode_text(doctext)
        self.margin = 2
        self.layout = layout.IncrementalTextLayout(self.document,
            self.width - self.margin * 2, self.height - self.margin * 2,
            multiline=True,
            batch=self.batch)
        self.layout.content_valign = 'center'
        self.caret = caret.Caret(self.layout)
        self.push_handlers(self.caret)

        self.set_mouse_cursor(self.get_system_mouse_cursor('text')) 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:17,代码来源:CONTENT_VALIGN_CENTER.py

示例6: __init__

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, *args, **kwargs):
        super(TestWindow, self).__init__(*args, **kwargs)

        self.batch = graphics.Batch()
        self.document = text.decode_text(doctext)
        self.margin = 2
        self.layout = layout.IncrementalTextLayout(self.document,
            self.width - self.margin * 2, self.height - self.margin * 2,
            multiline=True,
            batch=self.batch)
        self.layout.content_valign = 'bottom'
        self.caret = caret.Caret(self.layout)
        self.push_handlers(self.caret)

        self.set_mouse_cursor(self.get_system_mouse_cursor('text')) 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:17,代码来源:CONTENT_VALIGN_BOTTOM.py

示例7: __init__

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, *args, **kwargs):
        super(TestWindow, self).__init__(*args, **kwargs)

        self.batch = graphics.Batch()
        self.document = text.decode_attributed(doctext)
        self.margin = 2
        self.layout = layout.IncrementalTextLayout(self.document,
            self.width - self.margin * 2, self.height - self.margin * 2,
            multiline=True,
            batch=self.batch)
        self.caret = caret.Caret(self.layout)
        self.push_handlers(self.caret)

        self.set_mouse_cursor(self.get_system_mouse_cursor('text')) 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:16,代码来源:STYLE.py

示例8: __init__

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, *args, **kwargs):
        super(TestWindow, self).__init__(*args, **kwargs)

        self.batch = graphics.Batch()
        self.document = text.decode_text(doctext)
        self.margin = 2
        self.layout = layout.IncrementalTextLayout(self.document,
            self.width - self.margin * 2, self.height - self.margin * 2,
            multiline=True,
            batch=self.batch)
        self.caret = caret.Caret(self.layout)
        self.push_handlers(self.caret)

        self.set_mouse_cursor(self.get_system_mouse_cursor('text')) 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:16,代码来源:PLAIN.py

示例9: __init__

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, doctype, *args, **kwargs):
        super(TestWindow, self).__init__(*args, **kwargs)

        self.batch = graphics.Batch()
        self.document = doctype()
        self.layout = layout.IncrementalTextLayout(self.document,
            self.width, self.height, batch=self.batch) 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:9,代码来源:EMPTY.py

示例10: _create_text

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def _create_text(self):
        assert self.window is not None
        self.text_batch = Batch()
        self.text_document = FormattedDocument()
        layout = TextLayout(self.text_document, self.window.width, self.window.height,
                multiline=True, wrap_lines=True, batch=self.text_batch)
        layout.content_valign = 'bottom' 
开发者ID:pyglet,项目名称:pyglet,代码行数:9,代码来源:event_loop.py

示例11: draw

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def draw(self):
        """Draw the shape at its current position.

        Using this method is not recommended. Instead, add the
        shape to a `pyglet.graphics.Batch` for efficient rendering.
        """
        self._group.set_state_recursive()
        self._vertex_list.draw(GL_TRIANGLES)
        self._group.unset_state_recursive() 
开发者ID:pyglet,项目名称:pyglet,代码行数:11,代码来源:shapes.py

示例12: __init__

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, x, y, radius, segments=25, angle=math.pi*2, color=(255, 255, 255), batch=None, group=None):
        # TODO: Finish this shape and add docstring.
        self._x = x
        self._y = y
        self._radius = radius
        self._segments = segments
        self._rgb = color
        self._angle = angle

        self._batch = batch or Batch()
        self._group = _ShapeGroup(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, group)

        self._vertex_list = self._batch.add(self._segments*2, GL_LINES, self._group, 'v2f', 'c4B')
        self._update_position()
        self._update_color() 
开发者ID:pyglet,项目名称:pyglet,代码行数:17,代码来源:shapes.py

示例13: batch

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def batch(self):
        """The graphics Batch that the Model belongs to.

        The Model can be migrated from one batch to another, or removed from
        a batch (for individual drawing). If not part of any batch, the Model
        will keep it's own internal batch. Note that batch migration can be
        an expensive operation.

        :type: :py:class:`pyglet.graphics.Batch`
        """
        return self._batch 
开发者ID:pyglet,项目名称:pyglet,代码行数:13,代码来源:__init__.py

示例14: batch

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def batch(self, batch):
        if self._batch == batch:
            return

        if batch is None:
            self._batch = graphics.Batch()
            self._own_batch = True
            self._update()
        elif batch is not None:
            self._batch = batch
            self._own_batch = False
            self._update() 
开发者ID:pyglet,项目名称:pyglet,代码行数:14,代码来源:layout.py

示例15: __init__

# 需要导入模块: from pyglet import graphics [as 别名]
# 或者: from pyglet.graphics import Batch [as 别名]
def __init__(self, x: int, y: int):
        self.tile_images = {
            TileType.WATER: WATER_TILE,
            TileType.ICE: ICE_TILE,
            TileType.WEAK_ICE: WEAK_ICE_TILE,
            TileType.WALL: WALL_TILE
        }

        self.x = x
        self.y = y

        self.batch = Batch()

        # Tiles is in the format [y][x]
        self.tiles = [] 
开发者ID:python-discord,项目名称:code-jam-5,代码行数:17,代码来源:tile_layer.py


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