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


Python TextNode.set_font方法代码示例

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


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

示例1: FastTextNode

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import set_font [as 别名]
class FastTextNode(DebugObject):

    """ Interface for the Panda3D TextNode. """

    def __init__(self, font="Data/Font/Roboto-Bold.ttf", pixel_size=16, align="left",
                 pos=Vec2(0), color=Vec3(1), parent=None):
        self._node = TextNode('FTN')
        self._node.set_text("Text")
        self._node.set_align(getattr(TextNode, "A_" + align))
        self._node.set_text_color(color.x, color.y, color.z, 1)

        if parent is None:
            parent = Globals.base.aspect2d

        self._nodepath = parent.attach_new_node(self._node)
        self._nodepath.set_scale(pixel_size * 2.0 / float(Globals.base.win.get_y_size()))
        self._nodepath.set_pos(pos.x, 0, pos.y)

        font = Globals.loader.loadFont(font)
        font.set_outline(Vec4(0, 0, 0, 0.78), 1.6, 0.37)
        font.set_scale_factor(1.0)
        font.set_texture_margin(int(pixel_size / 4.0 * 2.0))
        font.set_bg(Vec4(0, 0, 0, 0))

        self._node.set_font(font)

    def set_text(self, text):
        self._node.set_text(text)
开发者ID:wdmwdm,项目名称:RenderPipeline,代码行数:30,代码来源:FastTextNode.py

示例2: GUI

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import set_font [as 别名]
class GUI(object):

    """ Handles the gui elements like showing the current stage """

    def __init__(self, control):

        self.control = control
        self.gui_node = pixel2d.attach_new_node("GUI")
        self.gui_node.hide()
        self.gui_node.set_transparency(True)

        roboto_light = loader.loadFont("res/Roboto-Light.ttf")
        roboto_light.set_scale_factor(1)
        roboto_light.set_pixels_per_unit(120)

        self.text_stage = TextNode("TextStage")
        self.text_stage.set_text("Stage 1")
        self.text_stage.set_align(TextNode.A_left)
        self.text_stage.set_text_color(1, 1, 1, 1)
        self.text_stage.set_font(roboto_light)
        self.text_stage_np = self.gui_node.attach_new_node(self.text_stage)
        self.text_stage_np.set_scale(80.0)
        self.text_stage_np.set_pos(60, 0, -120)

        self.anim = None

    def show(self):
        self.gui_node.show()
        if self.anim is not None:
            self.anim.finish()
        self.anim = Sequence(
            LerpColorScaleInterval(self.gui_node, 0.2, Vec4(1), Vec4(1, 1, 1, 0), blendType="easeInOut")
        )
        self.anim.start()

    def hide(self):
        self.gui_node.hide()
        if self.anim is not None:
            self.anim.finish()
        self.anim = Sequence(
            LerpColorScaleInterval(self.gui_node, 0.2, Vec4(1, 1, 1, 0), Vec4(1), blendType="easeInOut")
        )
        self.anim.start()


    def set_stage(self, stage_nr):
        print(("Setting stage", stage_nr))

        Sequence(
            LerpColorScaleInterval(self.text_stage_np, 0.4, Vec4(1, 1, 1, 0), Vec4(1), blendType="easeInOut"),
            Func(lambda *args: self.text_stage.set_text("Stage " + str(stage_nr))),
            LerpColorScaleInterval(self.text_stage_np, 0.4, Vec4(1), Vec4(1, 1, 1, 0), blendType="easeInOut"),
        ).start()
开发者ID:tobspr,项目名称:RenderPipeline-Samples,代码行数:55,代码来源:GUI.py

示例3: TextNode

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import set_font [as 别名]
class TextNode(RPObject):

    """ Interface for the Panda3D TextNode. """

    def __init__(self, font="/$$rp/data/font/Roboto-Bold.ttf", pixel_size=16, align="left",
                 pos=Vec2(0), color=Vec3(1), parent=None):
        """ Constructs a new text node, forwaring the parameters to the internal
        panda3d implementation """
        RPObject.__init__(self)
        self._node = TextNodeImpl('FTN')
        self._node.set_text("")
        self._node.set_align(getattr(TextNodeImpl, "A_" + align))
        self._node.set_text_color(color.x, color.y, color.z, 1)

        if parent is None:
            parent = Globals.base.aspect2d

        self._nodepath = parent.attach_new_node(self._node)
        self._nodepath.set_pos(pos.x, 0, pos.y)

        font = RPLoader.load_font(font)
        # font.set_outline(Vec4(0, 0, 0, 0.78), 1.6, 0.37)
        font.set_outline(Vec4(0, 0, 0, 1), 1.6, 0.37)
        font.set_scale_factor(1.0)
        font.set_texture_margin(int(pixel_size / 4.0 * 2.0))
        font.set_bg(Vec4(0, 0, 0, 0))
        self._node.set_font(font)
        self.set_pixel_size(pixel_size)

    @property
    def text(self):
        """ Returns the current text """
        return self._node.get_text()

    @text.setter
    def text(self, text):
        """ Sets the current text """
        self._node.set_text(text)

    @property
    def color(self):
        """ Returns the current text color """
        return self._node.get_text_color()

    @color.setter
    def color(self, val):
        """ Sets the current text color """
        self._node.set_text_color(val)

    def set_pixel_size(self, size):
        """ Sets the text size in pixels """
        self._nodepath.set_scale(size * 2.0 / float(Globals.native_resolution.y))
开发者ID:jakogut,项目名称:RenderPipeline,代码行数:54,代码来源:text_node.py


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