本文整理汇总了Python中echomesh.expression.Expression.expression方法的典型用法代码示例。如果您正苦于以下问题:Python Expression.expression方法的具体用法?Python Expression.expression怎么用?Python Expression.expression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类echomesh.expression.Expression
的用法示例。
在下文中一共展示了Expression.expression方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_player
# 需要导入模块: from echomesh.expression import Expression [as 别名]
# 或者: from echomesh.expression.Expression import expression [as 别名]
def set_player(self, element,
level=1, pan=0, loops=1, begin=0, end=INF, length=INF, **kwds):
self._element = element
self._file = kwds.pop('file')
self._filename = Util.DEFAULT_AUDIO_DIRECTORY.expand(self._file)
if kwds:
LOGGER.error('Unused keywords %s', kwds)
self._passthrough = (level == 1 and pan == 0)
self._length = length
self._level = Expression.expression(level, element)
self._pan = Expression.expression(pan, element)
self._loops = loops
self._begin = begin
self._end = end
示例2: __init__
# 需要导入模块: from echomesh.expression import Expression [as 别名]
# 或者: from echomesh.expression.Expression import expression [as 别名]
def __init__(
self,
element,
loops=1,
position=(0, 0),
rotation=(0, 0, 0),
size=1,
duration=None,
z=DEFAULT_Z,
shader=None,
**kwds
):
super(ImageSprite, self).__init__()
import pi3d
self.element = element
self.imagename = IMAGE_DIRECTORY.expand(kwds.pop("file", None))
del kwds["type"]
if kwds:
s = "" if len(kwds) == 1 else "s"
LOGGER.error("Unknown keyword%s: %s", s, ", ".join(kwds))
self._loops = loops
self._loop_number = 0
self._position = Expression.expression(position, element)
self._rotation = Expression.expression(rotation, element)
self._size = Expression.expression(size, element)
self._z = Expression.expression(z, element)
self.element.time = 0 # elapsed time.
self._time = 0 # start time.
if duration is None:
for env in [self._position, self._rotation, self._size, self._z]:
if env.is_constant():
duration = max(duration, env.length)
if duration is None:
duration = INFINITY
else:
self._duration = Expression.convert(duration)
if not self._duration:
LOGGER.warning("An image sprite had a zero duration.")
if not ImageSprite.CACHE:
ImageSprite.CACHE = pi3d.TextureCache()
texture = ImageSprite.CACHE.create(self.imagename)
x, y, z = self.coords()
self.sprite = pi3d.ImageSprite(texture, w=texture.ix, h=texture.iy, shader=Shader.shader(shader), x=x, y=y, z=z)
self.sprite.repaint = self.repaint
示例3: set_player
# 需要导入模块: from echomesh.expression import Expression [as 别名]
# 或者: from echomesh.expression.Expression import expression [as 别名]
def set_player(player, element,
level=1, pan=0, loops=1, begin=0, end=-1, length=-1, **kwds):
kwds.pop('type', None)
player._element = element
player._file = kwds.pop('file')
player._filename = Util.DEFAULT_AUDIO_DIRECTORY.expand(player._file)
if kwds:
LOGGER.error('Unused keywords %s', kwds)
player._passthrough = (level == 1 and pan == 0)
player._length = length
player._level = Expression.expression(level, element)
player._pan = Expression.expression(pan, element)
player._loops = loops
player._begin = begin
player._end = end
示例4: make_table_and_patterns
# 需要导入模块: from echomesh.expression import Expression [as 别名]
# 或者: from echomesh.expression.Expression import expression [as 别名]
def make_table_and_patterns(pattern_desc, attributes):
table = {}
patterns = []
desc = pattern_desc.description
pd = pattern_desc
try:
for k, v in six.iteritems(desc):
if not k.startswith('pattern'):
if k in attributes:
v = Expression.expression(v, pattern_desc.element)
table[k] = v
pats = desc.get('patterns') or desc.get('pattern') or []
if type(pats) is not list:
pats = [pats]
for p in pats:
pd = _PatternDesc(pattern_desc.element, p, pattern_desc.name)
pattern = _make_pattern(pd, False)
if pattern:
patterns.append(pattern)
except Exception as e:
if RAISE_ORIGINAL_EXCEPTION:
raise
else:
raise Exception('%s in %s' % (e, pd))
return table, patterns
示例5: __init__
# 需要导入模块: from echomesh.expression import Expression [as 别名]
# 或者: from echomesh.expression.Expression import expression [as 别名]
def __init__(self, desc, element, name):
self.name = name
self.element = element
desc = ReadObservingDictionary(desc)
pat = desc.pop('pattern', [])
if isinstance(pat, dict):
pat = [pat]
elif isinstance(pat, six.string_types):
pat = split_on_commas(pat)
self._patterns = [make_pattern(element, p) for p in pat]
if self.PATTERN_COUNT is not None:
assert self.PATTERN_COUNT == len(self._patterns), (
"Pattern type %s expects %s subpatterns but got %d" %
(self.__class__.__name__,
self.PATTERN_COUNT,
len(self._patterns)))
self.dictionary = {}
self.is_constant = all(p.is_constant for p in self._patterns)
missing = []
self.constants = set()
for k, v in self.SETTINGS.items():
const = v.get('constant', self.CONSTANT)
literal = v.get('literal')
if const:
self.constants.add(k)
value = desc.get(k, v.get('default'))
if value is None and 'default' not in v:
missing.append(k)
else:
if literal:
expression = LiteralExpression(value)
elif const:
expression = ConstantExpression.constant_expression(value)
else:
expression = Expression.expression(value, element)
self.dictionary[k] = expression
self.is_constant = self.is_constant and expression.is_constant()
if missing:
raise Exception('%s is missing required arguments %s' %
(self, ', '.join(missing)))
unread = desc.unread()
if unread:
LOGGER.error(
"For pattern type %s, we didn't use the following parameters: %s",
self.__class__.__name__, ', '.join(unread))
self._in_precompute = True
self._precompute()
self._in_precompute = False
if self.is_constant:
self._value = self._evaluate();