main.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:simple-circle-packing 作者: inconvergent 项目源码 文件源码
def main():

  # make the canvas
  sur = cairo.ImageSurface(cairo.FORMAT_ARGB32, SIZE, SIZE)
  ctx = cairo.Context(sur)

  # scale canvas so that x and y ranges from 0 to 1.
  ctx.scale(SIZE, SIZE)

  # set the background color of the canvas
  ctx.set_source_rgba(*BACK)
  ctx.rectangle(0.0, 0.0, 1.0, 1.0)
  ctx.fill()

  ctx.set_line_width(LINEWIDTH)


  circles = []
  add_new_circles(NEW_COUNT, circles)

  for i in xrange(STEPS):

    increase_radius(circles)

    ok_count = test(circles)

    if ok_count < 1:

      add_new_circles(NEW_COUNT, circles)

      print(i, 'adding new circles, total count: ' + str(len(circles)))

  show(ctx, circles)

  sur.write_to_png(RES)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号