Beispiel #1
0
    def render_scene(self,
                     params="none",
                     x_range=(-10, 10),
                     y_range=(-10, 10),
                     camera_position='default',
                     projection_type='none',
                     resolution=5,
                     density=5,
                     black_ref=-1.0,
                     white_ref=1.0,
                     default=hl.BLUE,
                     style='uniform',
                     region_params="none",
                     display=False,
                     save=False,
                     filename='default',
                     backdrop="new"):
        if params == "none":
            params = {}

        points, _ = self.frame_at_p(params=params,
                                    camera_position=camera_position,
                                    projection_type=projection_type,
                                    region_params=region_params,
                                    style=style,
                                    density=density)
        arr = hl.set_to_gradient(points=points,
                                 x_range=x_range,
                                 y_range=y_range,
                                 black_ref=black_ref,
                                 white_ref=white_ref,
                                 default=default,
                                 resolution=resolution,
                                 backdrop=backdrop)
        if display:
            hl.render_from_array(arr)
        if save:
            hl.save_img(arr, filename)
        return arr
Beispiel #2
0
import sys

sys.path.append('../hallucinator')
import hallucinator

topdown_gradient = lambda x, y: (x, y, -y)

conditions = (lambda x, y: y < x, lambda x, y: y > x**2 - 4)

gradient_along_path = hallucinator.conditional_region(f=topdown_gradient,
                                                      conditions=conditions,
                                                      x_range=(-5, 5),
                                                      y_range=(-5, 5),
                                                      density=10)

gradient_image = hallucinator.set_to_gradient(points=gradient_along_path,
                                              x_range=(-5, 5),
                                              y_range=(-5, 5),
                                              black_ref=-5,
                                              white_ref=5,
                                              resolution=20,
                                              default=hallucinator.BLACK)

# hallucinator.render_from_array(gradient_image)
hallucinator.save_img(gradient_image, 'conditional')
Beispiel #3
0
direction = (0, 0, 1)
x_range = (-20, 20)
y_range = (-20, 20)

zp = make_zone_plate(distance=distance,
                     wavelength=wavelength,
                     phase_diff=phase_diff,
                     a_density=a_density,
                     b_density=b_density,
                     direction=direction,
                     x_range=x_range,
                     y_range=y_range)

hl.render_from_array(zp)

hl.save_img(
    zp,
    'zoneplates/zoneplate_d{0}-w{1}-p{2}-a{3}-b{4}-dir{5}-xr{6}-yr{7}'.format(
        distance, wavelength, phase_diff, a_density, b_density, direction,
        x_range, y_range))
'''
hl.video(frame_func=lambda t: make_zone_plate(distance=distance,
                                              wavelength=wavelength,
                                              phase_diff=phase_diff,
                                              a_density=a_density,
                                              b_density=b_density*t,
                                              direction=direction),
         filename='zoneplates/zone_plate_change_b_density',
         t_range=(1, 5),
         FPS=10)'''
Beispiel #4
0
import sys

sys.path.append('../hallucinator')
import hallucinator

hallucinator.save_img(hallucinator.canvas(1000, 1000, color=(0, 0, 0)), filename='black')
'''hallucinator.save_img(hallucinator.canvas(1000, 1000, color=(0, 0, 254)), filename='almost_blue')
hallucinator.save_img(hallucinator.canvas(1000, 1000, color=(1, 0, 255)), filename='blue_with_red')
hallucinator.save_img(hallucinator.canvas(1000, 1000, color=(10, 0, 255)), filename='blue_with_more_red')'''

Beispiel #5
0
import sys
sys.path.append('../hallucinator')
import hallucinator

topdown_discrete = lambda x, y: (x, y, -1 if y < 0 else 1)
topdown_gradient = lambda x, y: (x, y, -y)

path = lambda p: (p, p)
p_range = [-3, 3]
gradient_along_path = hallucinator.path_region(f=topdown_gradient,
                                               path=path,
                                               p_range=p_range,
                                               density=5)

gradient_image = hallucinator.set_to_gradient(points=gradient_along_path,
                                              x_range=(-5, 5),
                                              y_range=(-5, 5),
                                              black_ref=-3,
                                              white_ref=3,
                                              default=hallucinator.BLUE)

# hallucinator.render_from_array(gradient_image)
hallucinator.save_img(gradient_image, 'path_grad_test0')
print(hl.intensity_at(sources=[source1], location=(1, 0)))
print(hl.intensity_at(sources=[source2], location=(1, 0)))
print(hl.intensity_at(sources=[source1, source2], location=(1, 0)))
print(hl.intensity_at(sources=[source1, source2], location=(1.01, 0)))'''

a_range = (-1, 1)
b_range = (-1, 1)

intensities = hl.eval_surface_intensity(
    sources=[*line_of_sources],
    surface=surface,
    a_range=a_range,
    b_range=b_range,
    a_density=2000,
    b_density=2000,
    # density=100
)
canv = hl.set_to_gradient(
    intensities,
    x_range=a_range,
    y_range=b_range,
    black_ref=0,
    white_ref=4.0,
    default=hl.GRAY,
    resolution=2000,
)

hl.render_from_array(canv)
hl.save_img(canv, 'width{0}_{1}-points_random'.format(slit_width, num_sources))
#hl.save_img(canv, 'two_point_stacked')
Beispiel #7
0
source = (0, 0, 0)
direction = (0, 0, 1)

planewave = hl.PlaneWave(source=source,
                         wavelength=0.05,
                         amplitude=1,
                         init_phase=0,
                         direction=direction)

spherewave = hl.PointSource(source=source,
                            wavelength=0.05,
                            amplitude=1,
                            init_phase=math.pi / 2)

points = hl.eval_surface_intensity(sources=(planewave, spherewave),
                                   surface=surface,
                                   a_range=(-15, 15),
                                   b_range=(-15, 15),
                                   density=15)

canv = hl.set_to_gradient(points,
                          x_range=(-15, 15),
                          y_range=(-15, 15),
                          black_ref=0,
                          white_ref=4.0,
                          default=hl.GRAY,
                          resolution=50)

hl.render_from_array(canv)
hl.save_img(canv, 'w0.05-d10-15-15-p0.5pi')
Beispiel #8
0
                    """ upper right """
                    plane[x][y] = math.sin(((x - split + offset_scale*math.cos(t)) ** 2
                                            - (y - split - offset_scale*math.sin(t)) ** 2
                                           - (offset_scale * math.cos(t))**2 - (offset_scale*math.cos(t))**2)
                                           / size)# - math.pi / 2)
                else:
                    """ upper left """
                    plane[x][y] = math.sin(((x - split + offset_scale*math.cos(t)) ** 2
                                            + (y - split + offset_scale*math.sin(t)) ** 2
                                            + (-offset_scale * math.cos(t))**2 + (offset_scale*math.sin(t))**2)
                                           / size)
    return hl.imagify(plane, hsv=False)


#hl.render_from_array(hl.imagify(birth(1000)))
'''filename = '../images/zonepinch{0}.png'.format(offset)
hl.save_img(img, filename)'''

params = dict(
        frame_function=lambda d: birth(**d),
        frame_arguments=hl.unroll_dict(dict(
            t=hl.np.linspace(0, math.pi, num=200),
        )),
        filename=f"../videos/birth",
        fps=10,
        preview=True,
        parallel_frames=False,
    )

hl.video(**params)
Beispiel #9
0
    canv = hl.set_to_gradient(points,
                              x_range=(-15, 15),
                              y_range=(-15, 15),
                              black_ref=0,
                              white_ref=4.0,
                              default=hl.GRAY,
                              resolution=50)

    return canv


angle = math.pi / 180
a_direction = (0, math.sin(angle), math.cos(angle))
b_direction = (0, -math.sin(angle), math.cos(angle))
distance = 10
wavelength = 0.1
phase_diff = 0

canv = plane_interference(distance=distance,
                          wavelength=wavelength,
                          phase_diff=phase_diff,
                          sampling_density=20,
                          a_direction=a_direction,
                          b_direction=b_direction)

hl.render_from_array(canv)
hl.save_img(
    canv,
    'planewaves/planewaves_{0}-w{1}-p{2}-a{3}'.format(distance, wavelength,
                                                      phase_diff, angle))
Beispiel #10
0
                              default=hl.GRAY,
                              resolution=50)

    return canv


distance = 15
wavelength = 0.05
phase_diff = 0
density = 300
direction = (0, 0, 1)

zp = make_zone_plate(distance=distance,
                     wavelength=wavelength,
                     phase_diff=phase_diff,
                     density=density,
                     direction=direction)

hl.render_from_array(zp)

hl.save_img(zp, 'zoneplates/zoneplate_rand_d{0}-w{1}-p{2}-d{3}-dir{4}'.format(distance, wavelength, phase_diff,
                                                                         density, direction))

'''hl.video(frame_func=lambda t: make_zone_plate(distance=15,
                                              wavelength=0.1,
                                              phase_diff=0,
                                              sampling_density=15),
         filename='zone_plate_change_sample_rate_5',
         t_range=(2, 6),
         FPS=10)'''