示例#1
0
# print computed roots
print "Computed " + str(len(roots)) + " roots of " + f_val.__name__
if len(roots) < 8:
    for root in roots:
        print "%.4f \t+\t%.4fi" % (root.real, root.imag)

# plot newton fractal
col_source = 'colourlovers'
# col_params = {'lover': 'joy_of_summer', 'keywords': 'I like your Smile', 'cmap':'spring', 'col_num':len(p)}
# col_params = {'lover': 'QitsuneQage', 'keywords': 'Almost Together', 'cmap':'jet', 'col_num':len(p)}
# col_params = {'lover': 'joy_of_summer', 'keywords': 'See The Light', 'cmap':'spectral', 'col_num':len(p)}
# col_params = {'lover': 'pseudo.cyborg', 'keywords': 'math music', 'cmap':'summer', 'col_num':len(p)}
# col_params = {'lover': 'silentHue', 'keywords': 'Mute Math EP', 'cmap':'winter', 'col_num':len(p)}
# col_params = {'lover': 'yakotta', 'keywords': 'blue hour', 'cmap':'gnuplot', 'col_num':len(p)}
# col_params = {'lover': 'owlies', 'keywords': 'endlessly.', 'cmap':'gnuplot', 'col_num':len(p)}
col_params = {
    'lover': 'justjessi',
    'keywords': 'groovy kind of xmas',
    'cmap': 'gnuplot',
    'col_num': 256
}
# col_params = {'lover': 'MarieBrandt', 'keywords': 'Barcelona', 'cmap':'gnuplot', 'col_num':len(p)}

colors = gn.config_colors(col_source, col_params)
save_path = "fractal_pictures/frac_40.png"
gn.newton_plot(con_root, con_num, colors, save_path)

# replace the above line with
#		gn.newton_plot(con_num, con_num, colors, save_path)
# to color by number of iterations
示例#2
0
# colors
colors = [(0, 255, 255), (128, 128, 255), (255, 0, 255), (255, 128, 128)]

# generalized newton parameter, a
a_seq = np.linspace(1.5, 0.6, 600)

# create image sequence
i = 1
for a in a_seq:
    # print progress
    img_file_name = directory + '/' + imagename + '%05d' % i + '.png'
    print 'Creating frame ' + str(i) + ' of ' + str(a_seq.size)
    i += 1

    # newton's method
    roots, con_root, con_num = gn.newton_method(Z,
                                                f_val,
                                                df_val,
                                                params,
                                                a=a,
                                                disp_time=False,
                                                known_roots=known_roots)

    # create image in folder
    gn.newton_plot(con_root, con_num, colors, save_path=img_file_name)

# create the movie
ctrlStr = 'ffmpeg -r %d -i %s%%05d.png -c:v libx264 -preset slow -crf %d %s' % (
    frame_ps, directory + '/' + imagename, quality, filename)
subprocess.call(ctrlStr, shell=True)
示例#3
0
    print 'Creating frame ' + str(i + 1) + ' of ' + str(num_times)

    # create polynomial from roots
    known_roots = param_roots[i, :]
    p = np.flipud(poly.polyfromroots(known_roots))
    dp = tf.poly_der(p)

    # update param dictionary
    params['p'] = p
    params['dp'] = dp

    # newton's method
    roots, con_root, con_num = gn.newton_method(Z,
                                                f_val,
                                                df_val,
                                                params,
                                                disp_time=False,
                                                known_roots=known_roots,
                                                max_iter=max_iter)

    # create image in folder
    gn.newton_plot(con_root,
                   con_num,
                   colors,
                   save_path=img_file_name,
                   max_shade=max_iter)

# create the movie
ctrlStr = 'ffmpeg -r %d -i %s%%05d.png -c:v libx264 -preset slow -crf %d %s' % (
    frame_ps, directory + '/' + imagename, quality, filename)
subprocess.call(ctrlStr, shell=True)
示例#4
0
max_iter = 50

# run newton's method
roots, con_root, con_num = gn.newton_method(Z, f_val, df_val, params, max_iter=max_iter)

# print computed roots
print "Computed " + str(len(roots)) + " roots of " + f_val.__name__
if len(roots) < 8:
    for root in roots:
        print "%.4f \t+\t%.4fi" %(root.real, root.imag)

# plot newton fractal
col_source = 'colourlovers'
# col_params = {'lover': 'joy_of_summer', 'keywords': 'I like your Smile', 'cmap':'spring', 'col_num':len(p)}
# col_params = {'lover': 'QitsuneQage', 'keywords': 'Almost Together', 'cmap':'jet', 'col_num':len(p)}
# col_params = {'lover': 'joy_of_summer', 'keywords': 'See The Light', 'cmap':'spectral', 'col_num':len(p)}
# col_params = {'lover': 'pseudo.cyborg', 'keywords': 'math music', 'cmap':'summer', 'col_num':len(p)}
# col_params = {'lover': 'silentHue', 'keywords': 'Mute Math EP', 'cmap':'winter', 'col_num':len(p)}
# col_params = {'lover': 'yakotta', 'keywords': 'blue hour', 'cmap':'gnuplot', 'col_num':len(p)}
# col_params = {'lover': 'owlies', 'keywords': 'endlessly.', 'cmap':'gnuplot', 'col_num':len(p)}
col_params = {'lover': 'justjessi', 'keywords': 'groovy kind of xmas', 'cmap':'gnuplot', 'col_num':256}
# col_params = {'lover': 'MarieBrandt', 'keywords': 'Barcelona', 'cmap':'gnuplot', 'col_num':len(p)}

colors = gn.config_colors(col_source, col_params)
save_path = "fractal_pictures/frac_40.png"
gn.newton_plot(con_root, con_num, colors, save_path)

# replace the above line with 
#		gn.newton_plot(con_num, con_num, colors, save_path)
# to color by number of iterations
示例#5
0
# get parameterized roots
speeds = np.array([1,4,1,4])
num_times = vid_len * frame_ps
param_roots = tf.parameterized_roots1(speeds, num_times)
max_iter = 50

# create image sequence
for i in range(num_times):
    # print progress
    img_file_name = directory + '/' + imagename + '%05d' % (i+1) + '.png'
    print 'Creating frame ' + str(i+1) + ' of ' + str(num_times)

    # create polynomial from roots
    known_roots = param_roots[i,:]
    p = np.flipud(poly.polyfromroots(known_roots))
    dp = tf.poly_der(p)

    # update param dictionary
    params['p'] = p
    params['dp'] = dp

    # newton's method
    roots, con_root, con_num = gn.newton_method(Z, f_val, df_val, params, disp_time=False, known_roots=known_roots, max_iter = max_iter)

    # create image in folder
    gn.newton_plot(con_root, con_num, colors, save_path=img_file_name, max_shade=max_iter)

# create the movie
ctrlStr = 'ffmpeg -r %d -i %s%%05d.png -c:v libx264 -preset slow -crf %d %s' %(frame_ps, directory + '/' + imagename, quality, filename)
subprocess.call(ctrlStr, shell=True)
示例#6
0
df_val = tf.d_poly_fun
known_roots = np.roots(p)

# frame parameters
vid_len = 5  # length of gif
frame_ps = 18  # number of frames per second
quality = 22 # the quality of the encoding

# colors
colors = [(0, 255, 255), (128, 128, 255), (255, 0, 255), (255, 128, 128)]

# generalized newton parameter, a
a_seq = np.linspace(1.5, 0.6, 600)

# create image sequence
i = 1
for a in a_seq:
    # print progress
    img_file_name = directory + '/' + imagename + '%05d' % i + '.png'
    print 'Creating frame ' + str(i) + ' of ' + str(a_seq.size)
    i += 1

    # newton's method
    roots, con_root, con_num = gn.newton_method(Z, f_val, df_val, params, a=a, disp_time=False, known_roots=known_roots)

    # create image in folder
    gn.newton_plot(con_root, con_num, colors, save_path=img_file_name)

# create the movie
ctrlStr = 'ffmpeg -r %d -i %s%%05d.png -c:v libx264 -preset slow -crf %d %s' %(frame_ps, directory + '/' + imagename, quality, filename)
subprocess.call(ctrlStr, shell=True)