Attachment 'DeepWood_gen.py'

Download

   1 #!/usr/bin/env python3
   2 '''
   3 '''
   4 from random import *
   5 import sys
   6 
   7 NTREES = 40 if len(sys.argv)<2 else int(sys.argv[1])
   8 MINR = 5 if len(sys.argv)<3 else int(sys.argv[2])
   9 MAXR = 50 if len(sys.argv)<4 else int(sys.argv[3])
  10 SIZE = (1024, 768) if len(sys.argv)<6 else (int(sys.argv[4]), int(sys.argv[5]))
  11 
  12 def gen_les(O, n, minR=MINR, maxR=MAXR, size=SIZE):
  13     while n>0:
  14         r=randint(minR,maxR)
  15         x,y=randint(r+1,size[0]-r-1),randint(r+1,size[1]-r-1)
  16         if (O[0]-x)**2+(O[1]-y)**2>r**2:
  17             yield x, y, r
  18             n-=1
  19 
  20 X, Y = randrange(2*SIZE[0]//5, 3*SIZE[0]//5), randrange(2*SIZE[1]//5, 3*SIZE[1]//5)
  21 
  22 
  23 print(*gen_les((X, Y), NTREES, MINR, MAXR, SIZE), sep=", ")
  24 print(f"{X}, {Y}")

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.