本文整理汇总了Python中panda3d.core.TextNode.getFrameActual方法的典型用法代码示例。如果您正苦于以下问题:Python TextNode.getFrameActual方法的具体用法?Python TextNode.getFrameActual怎么用?Python TextNode.getFrameActual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.TextNode
的用法示例。
在下文中一共展示了TextNode.getFrameActual方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTextSize
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import getFrameActual [as 别名]
def getTextSize(txt, style):
tn = TextNode(txt)
tn.setText(txt)
tn.setFont(loader.loadFont(style['font']))
tn.setSlant(style['slant'])
#tn.setFont(style['font'])
fontSize = style['font-size']
lineHeight = tn.getLineHeight()
f = tn.getFrameActual()
return (tn.getWidth()*fontSize,\
(f[3]-f[2])*fontSize,\
lineHeight*fontSize,\
(0, f[1]*fontSize, f[2]*fontSize, f[3]*fontSize))
示例2: WhisperPopup
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import getFrameActual [as 别名]
#.........这里部分代码省略.........
if self.quitButton is not None:
self.quitButton.destroy()
self.quitButton = None
self.contents.node().removeAllChildren()
self.draw()
if self.cell is not None:
# We're in the margin display. Reposition our content, and update
# the click region:
self.reposition()
self.updateClickRegion()
else:
# We aren't in the margin display. Disable the click region if one
# is present:
if self.region is not None:
self.region.setActive(False)
def draw(self):
if self.isClickable():
foreground, background = self.whisperColor[self.clickState]
else:
foreground, background = self.whisperColor[PGButton.SInactive]
self.chatBalloon = ChatBalloon(
NametagGlobals.chatBalloon2dModel,
NametagGlobals.chatBalloon2dWidth,
NametagGlobals.chatBalloon2dHeight, self.textNode,
foreground=foreground, background=background
)
self.chatBalloon.reparentTo(self.contents)
# Calculate the center of the TextNode:
left, right, bottom, top = self.textNode.getFrameActual()
center = self.contents.getRelativePoint(
self.chatBalloon.textNodePath,
((left+right) / 2.0, 0, (bottom+top) / 2.0))
# Translate the chat balloon along the inverse:
self.chatBalloon.setPos(self.chatBalloon, -center)
# Draw the quit button:
self.quitButton = WhisperQuitButton(self)
quitButtonNodePath = self.contents.attachNewNode(self.quitButton)
# Move the quit button to the top right of the TextNode:
quitButtonNodePath.setPos(self.contents.getRelativePoint(
self.chatBalloon.textNodePath, (right, 0, top)))
# Apply the quit button shift:
quitButtonNodePath.setPos(quitButtonNodePath, self.QUIT_BUTTON_SHIFT)
# Allow the quit button to close this whisper:
self.quitButton.setClickEvent(self.quitEvent)
def manage(self, marginManager):
MarginVisible.manage(self, marginManager)
self.timeoutTask = taskMgr.doMethodLater(
self.timeout, self.unmanage, self.timeoutTaskName, [marginManager])
def unmanage(self, marginManager):
MarginVisible.unmanage(self, marginManager)
self.destroy()