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


Python Tag.collidesWith方法代码示例

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


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

示例1: Tag

# 需要导入模块: from tag import Tag [as 别名]
# 或者: from tag.Tag import collidesWith [as 别名]
    #tag = Tag(word, colors.next(), font = f)
    tag = Tag(word, f, hsv2rgb((i*inc+240)%360,0.9,0.8))

    positions = [(width/2-tag.text.width/2,height/2-tag.text.height/2)]
    for t in tags:
        positions.append((t.left          , t.top+padding))
        positions.append((t.right+padding , t.bottom))
        positions.append((t.left          , t.bottom-tag.text.height-padding))
        positions.append((t.left-tag.text.width-padding, t.bottom))

    while not added:
        try_pos = positions.pop(0)
        tag.setPos(try_pos)
        added=True
        if tag.left < 0 or tag.bottom < 0 or \
           tag.top > height or tag.right > width:
            added=False
            continue

        for t in tags:
            if tag.collidesWith(t):
                added=False
                break

    tags.append(tag)

##pyglet.clock.schedule_interval(main_update, 1/60.0)
##window.push_handlers(pyglet.window.event.WindowEventLogger())

pyglet.app.run()
开发者ID:jpypi,项目名称:TagCloud,代码行数:32,代码来源:main.py


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