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


Python World.ca方法代码示例

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


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

示例1: int

# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import ca [as 别名]
"""
# Code used to calculate dementions of left approx-equilateral triangle
end_count = 20000
a = 1
while a < end_count:
  c = math.sqrt(5*(a**2))
  c_int = int(c)
  if (abs(c-c_int) <= 5) and (abs(c_int - (2*a)) <= 5) : print a, c
  a += 1


"""
from World import World

width = 250
height = 250

world = World()
canvas = world.ca(width=width, height=height, background='grey')

left_triangle = [[-56,25], [0, 0], [-56, -25]] 
canvas.polygon(left_triangle, fill='blue')
top_polygon = [[-56,25], [56,25], [56,0], [0,0]]
canvas.polygon(top_polygon, fill='white')
bottom_polygon = [[-56,-25], [56,-25], [56,0], [0,0]]
canvas.polygon(bottom_polygon, fill='red')



world.mainloop()
开发者ID:B-Rich,项目名称:thinkPython-1,代码行数:32,代码来源:exc15_5.py

示例2: make_color_dict

# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import ca [as 别名]
# I need 28 by 28 grid to fit all 753 colors!
#
"""
if __name__ == '__main__':
    color_dict = make_color_dict()
    for name, rgb in color_dict.iteritems():
        print rgb, name
"""

from World import World
from exc15_4 import draw_rectangle
width = 750
height = 750
world = World()
canvas = world.ca(width=width, height=height, background='white')

if __name__ == '__main__':

  # there are less than 28**2 total colors
  tot_colors_root = 28
  swath_width = width/tot_colors_root
  swath_height = height/tot_colors_root

  # define upper left hand corner x and y
  quadrant_x = -(width/2)
  quadrant_y = height/2
  color_dict = make_color_dict()
  count = 1
  colors_count = len(color_dict)
  ###
开发者ID:B-Rich,项目名称:thinkPython-1,代码行数:32,代码来源:color_dict2.py

示例3: World

# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import ca [as 别名]
from World import World

world = World()
world.mainloop()

canvas = world.ca(width=500, height=500, background="white")
bbox = [[-150, -100], [150, 100]]
canvas.rectangle(bbox, outline="black", width=2, fill="green4")

canvas.circle([-25, 0], 70, outline=None, fill="red")
开发者ID:ErikRHanson,项目名称:think_python,代码行数:12,代码来源:ex4_swampy.py


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