예제 #1
0
 def __init__(self, script_path, width, height, seed=1138):
     super(DrawUtils, self).__init__(
         script_path, seed
     )  # Calls init from inherited class to get those variables first
     log.info(self.timestamp)
     self.width = width
     self.height = height
def draw():

    fc = (frameCount - 1) % len(colors)
    log.info(fc)

    pg.beginDraw()
    pg.noFill()

    pg.beginShape()
    angles = frange(0, TAU, TAU / 6)
    x_c = random(100)
    y_c = random(100)

    pg.stroke(colors[fc][0], colors[fc][1], colors[fc][2], args['alpha'])
    #pg.stroke(180, 100, 100, 50)
    pg.strokeWeight(60)

    for a in angles + angles[:3]:
        r = noise_loop(a, 100, -1 * args['width'] * 0.2, args['width'] * 0.8,
                       x_c, y_c)
        x, y = circle_point(args['width'] / 2, args['height'] / 2, r, r, a)
        pg.curveVertex(x, y)
    pg.endShape()

    pg.endDraw()

    if frameCount == 3 * len(colors):
        save_graphic(pg, 'output', 0)
        exit()
def draw():
    global good_color

    fc = (frameCount - 1) % len(colors)
    log.info(fc)

    pg.beginDraw()
    pg.noFill()

    pg.beginShape()
    angles = frange(0, TAU, TAU / 6)
    x_c = random(100)
    y_c = random(100)

    pg.stroke(colors[fc][0], colors[fc][1], colors[fc][2], args['alpha'])
    #pg.stroke(180, 100, 100, 50)
    pg.strokeWeight(60)

    for a in angles + angles[:3]:
        r = noise_loop(a, 100, 0, args['width'] * 0.7, x_c, y_c)
        x, y = circle_point(args['width'] / 2, args['height'] / 2, r, r, a)
        pg.curveVertex(x, y)
    pg.endShape()

    pg.endDraw()

    def extract_colors(filename):
        img = loadImage(filename)
        # 800 x 1156
        for x in range(img.width):
            for y in range(img.height):
                c = img.get(x, y)
                found = False
                for n in range(args['numpal']):
                    if c == good_color[n]:
                        found = True
                        break
                if not found:
                    if args['numpal'] < args['maxpal']:
                        good_color.append(c)
                        args['numpal'] += 1

    extract_colors('flowersA.jpg')
    out = createGraphics(22, 22)
    out.beginDraw()
    i = 0
    out.strokeWeight(1)
    for x in range(22):
        for y in range(22):
            out.stroke(good_color[i])
            out.point(x, y)
            i += 1
    out.endDraw()
    save_graphic(out, 'outputx', 0)

    print(good_color)

    if frameCount == 3 * len(colors):
        save_graphic(pg, 'output', 0)
        exit()
def save_graphic(pg, path, counter):
  make_dir(path)
  output_file = get_filename(counter)
  output_path = os.path.join(path, output_file)
  pg.save(output_path)
  log.info('Saved to {}'.format(output_path))
  if counter == 0:
    make_dir('archive_code')
    src = script_path
    dst = os.path.join('archive_code',output_file + '.py')
    shutil.copy(src, dst)
예제 #5
0
 def config_to_dict(self, config_path, config_section='default'):
     """
     Grabs section from config file and converts it to a dict
     """
     config = ConfigParser.ConfigParser()
     config.read(config_path)
     section_list = config.items(config_section)
     log.info('Args pulled from config file:')
     for pair in section_list:
         log.info('  {}: {}'.format(pair[0], pair[1]))
     section_dict = dict(section_list)
     section_dict = self.cast_dict(section_dict)
     return section_dict
예제 #6
0
파일: det.py 프로젝트: Ran4/det
def main():
    parser = get_toplevel_parser()
    
    if len(sys.argv) > 1:
        parsed_args = parser.parse_args()
        
        # Make sure --no-random overrides --random:
        # TODO: Figure out a way to do this with argparse's config 
        if parsed_args.no_random:
            parsed_args.random = False
            
        log.info("args: %s", parsed_args)
            
        det(parsed_args)
    else:
        args = parser.print_help()
        exit(1)
예제 #7
0
 def save_graphic(self, pg, path, counter):
     self.make_dir(path)
     output_file = self.get_filename(counter)
     output_path = os.path.join(path, output_file)
     pg.save(output_path)
     log.info('Saved to {}'.format(output_path))
예제 #8
0
 def print_seed(self):
     log.info(self.seed)