Пример #1
0
 def render(self, text, antialias, color, background=None):
     """
     Render text onto surface.
     Arguments:
     text to render (string)
     antialias of text (bool)
     color of text (R,G,B)
     background color (R,G,B)
     """
     w, h = self.size(text)
     surf = surface.Surface((w, h), BufferedImage.TYPE_INT_ARGB)
     g2d = surf.createGraphics()
     if background:
         g2d.setColor(Color(background))  #0.23
         g2d.fillRect(0, 0, w, h)
     g2d.setFont(self.font)
     if antialias:
         g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                              RenderingHints.VALUE_TEXT_ANTIALIAS_ON)
     g2d.setColor(Color(color))  #0.23
     g2d.drawString(text, 0,
                    (h // 2) + (self.fontMetrics.getAscent() // 2))  #0.22
     if self.underline:
         g2d.setStroke(BasicStroke(1))
         g2d.drawLine(0, h - 1, w - 1, h - 1)  #0.22
     g2d.dispose()
     return surf
Пример #2
0
 def render(self, text, antialias, color, background=None):
     """
     Render text onto surface.
     Arguments:
     text to render (string)
     antialias of text (bool)
     color of text (R,G,B)
     background color (R,G,B)
     """
     w,h = self.size(text)
     surf = surface.Surface((w,h), BufferedImage.TYPE_INT_ARGB)
     g2d = surf.createGraphics()
     if background:
         R,G,B = background
         g2d.setColor(Color(R,G,B))
         g2d.fillRect(0,0,w,h)
     g2d.setFont(self.font)
     if antialias:
         g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON)
     R,G,B = color
     g2d.setColor(Color(R,G,B))
     g2d.drawString(text,2,h//1.25+2)
     if self.underline:
         g2d.setStroke(BasicStroke(1))
         g2d.drawLine(2,h-4,w-3,h-4)
     g2d.dispose()
     return surf
Пример #3
0
    def __init__(self):
        window.Window.__init__(self)

        #f = fontsurface.FontSurface()
        #self.add_surface(f)

        self.s = surface.Surface('s')
        (self.x, self.y, self.z) = 100, 100, 0
        self.s.set_location(self.x, self.y, self.z)
        self.s.set_back_color(255, 0, 0)
        #s2 = surface.Surface('s2')
        #s2.set_back_color(255,255,0)
        #s2.set_location(100,100,0)
        #s3 = surface.Surface('s3')
        #s3.set_back_color(255,0,255)
        #s3.set_location(100,100,0)
        #self.s.add_surface(s2)
        #s2.add_surface(s3)
        self.add_surface(self.s)

        #self.t = surface.Surface('s')
        #self.add_surface(self.t)
        #self.t.set_location(self.x,self.y + 300,self.z)

        self.is_d = False
Пример #4
0
def main(argv):

    Deltas = np.arange(1, 21, 1)
    sim_time = []

    for DELTA_X in Deltas:
        sim_start_time = clock()

        # check if config is given as parameter
        if len(sys.argv) < 2:
            usage()
            exit()

        par.LoadConfig(sys.argv[1])

        dtime = par.TIME_STEP
        dt = dtime
        time = 0
        end_time = par.TOTAL_TIME

        surface_start = sf.Surface(par.XMAX, par.XMIN, DELTA_X)

        surface = sf.Surface(par.XMAX, par.XMIN, DELTA_X)
        while time < end_time:

            ad.advance(surface, dt)
            surface.write(time, surface.x.size, end_time, dtime)
            time, dt = ad.timestep(dtime, time, end_time)

        surface.write(time, surface.x.size, end_time, dtime)

        sim_end_time = clock()
        print("Execution time:" + str(sim_end_time - sim_start_time) + "s")
        sim_time.append(sim_end_time - sim_start_time)

    plt.plot(Deltas, np.array(sim_time))
    plt.ylabel('Simulationtime in s')
    plt.xlabel('DELTA_X')
    plt.show()

    sim_time_table = np.column_stack((Deltas, np.array(sim_time)))

    sim_time_table.tofile('timing.dat', sep=',', format='%s')

    if par.PLOT_SURFACE:
        surface_start.plot(end_time, dtime, 'OF Start', '-+r')
        surface.plot(end_time, dtime, 'OF Stop', '-+b')
Пример #5
0
def init():
    """
    **pyj2d.font.init**
    
    Initialize font module.
    """
    global _surf, _g2d, _initialized, match_font
    _surf = surface.Surface((1, 1), BufferedImage.TYPE_INT_RGB)
    _g2d = _surf.createGraphics()
    match_font = lambda *arg: None  #nonimplemented_methods
    _initialized = True
Пример #6
0
    def refresh_paraxial(self):
        self.EFL = first_order_tools.EFL(self, 0, 0)
        self.EPD = self.EFL / self.FNO
        self.EP_thickness = first_order_tools.EP(self)
        self.object_position = -1000000  # temporary only for infinity conjugate
        start = 2
        end = len(self.surface_list)
        OAL = first_order_tools.OAL(self, start, end)
        Pos_z = OAL * 0.2

        # entrance pupil fake surface use as surface 1
        self.surface_list[0] = surface.Surface(wavelength_list = self.wavelength_list,number=1,\
                radius=10000000,thickness=Pos_z,glass='air',STO=False,\
                __diameter__=0)
Пример #7
0
def simulation(path_to_cfg, path_to_srf=None):
    """Main Method to Simulate the etching process.

        :param path_to_cfg: path to the config file
    """
    par.initPar(path_to_cfg)
    init_sputtering()

    #Define Parameters
    surface = srf.Surface()
    time = 0

    # Path for Surface file = Path of Config file
    file_name = path_to_cfg.replace(".cfg", ".srf")

    # Create .srf file and write down initialization Surface
    surface.write(time, file_name, 'w')

    # Simulate Etching process until Max. Time is reached
    while time < par.TOTAL_TIME:

        adv.advance(surface)

        dt = adv.timestep(time)
        time += dt

        surface.write(time, file_name, 'a')

        # Stop the timer
        t_2 = timer()
        # Print out the computation time of the program
        print(t_2 - t_1)

    # Check if surface was already saved
    filelist = os.listdir()
    search_strg = file_name + '_save'
    is_saved = False
    for i in range(len(filelist)):
        if filelist[i] == search_strg:
            is_saved = True
            saved_file = str(filelist[i].split('.')[0]) + '.srf'
    # Plot the Surface
    # If the file was already saved print both original and saved file
    # in one plot
    if par.PLOT_SURFACE:
        if is_saved:
            plot.plot(file_name, saved_file)
        else:
            plot.plot(file_name)
    return surface
Пример #8
0
def self_affine(saparams, power_of_two, seed=None):
    np.random.seed(seed)
    lambda_L_over_lambda_0 = 1 if saparams.lambda_L_over_lambda_0 is None else saparams.lambda_L_over_lambda_0
    lambda_L_over_lambda_1 = sys.maxsize if saparams.lambda_L_over_lambda_1 is None else saparams.lambda_L_over_lambda_1
    N, L = 2**power_of_two, saparams.dimensions[0]
    power = -(saparams.hurst + 1.0)
    f_L = 1.0 / N  # rel frequency
    f_0, f_1 = f_L * lambda_L_over_lambda_0, f_L * lambda_L_over_lambda_1
    A = np.zeros((N, N), dtype=complex)
    center = int(N / 2)
    rand_norm_1, rand_norm_2 = np.random.randn(center + 1,
                                               center + 1), np.random.randn(
                                                   center + 1, center + 1)
    rand_unif_1, rand_unif_2 = np.random.rand(center + 1,
                                              center + 1), np.random.rand(
                                                  center + 1, center + 1)
    for i in range(0, int(N / 2 + 1)):
        for j in range(0, int(N / 2 + 1)):
            phase = 2.0 * np.pi * rand_unif_1[i, j]
            rad = 0.0
            f = np.sqrt((float(i) / N)**2 + (float(j) / N)**2)
            if i != 0 or j != 0:
                f = f if f > f_0 else f_0  # hi pass --> f_0
                rad = rand_norm_1[i, j] * f**power
            if f > f_1:  # lo pass --> f_1
                rad, phase = 0.0, 0.0
            # print "f = ", f, "rad = ", rad
            A[i, j] = rad * np.cos(phase) + rad * np.sin(phase) * 1j
            i0 = 0 if i == 0 else N - i
            j0 = 0 if j == 0 else N - j
            A[i0, j0] = rad * np.cos(phase) - rad * np.sin(phase) * 1j
    A[center, 0] = A[center, 0].real + 0j
    A[0, center] = A[0, center].real + 0j
    A[center, center] = A[center, center].real + 0j
    for i in range(1, center):
        for j in range(1, center):
            phase = 2.0 * np.pi * rand_unif_2[i, j]
            f = np.sqrt((float(i) / N)**2 + (float(j) / N)**2)
            f = f if f > f_0 else f_0  # hi pass --> f_0
            rad = rand_norm_2[i, j] * f**power
            if f > f_1:  # lo pass --> f_1
                rad, phase = 0., 0.
            A[i, N - j] = rad * np.cos(phase) + rad * np.sin(phase) * 1j
            A[N - i, j] = rad * np.cos(phase) - rad * np.sin(phase) * 1j
    H = np.real(np.fft.ifft2((A)))
    s = bs.Surface(H, L / float(N))
    s = bs.scale_to_rms(s, saparams.hrms)
    s = bs.shift_to_zero_mean(s)
    return s
Пример #9
0
 def parse(self):
     super(ParameterData128, self).parse()
     n, m, p, q = [int(p) for p in self.params[1:5]]
     U = self.params[10:10 + n + p + 2]
     V = self.params[10 + n + p + 2:10 + n + m + p + q + 4]
     w = self.params[10 + n + m + p + q + 4:10 + n + m + p + q + 4 +
                     (n + 1) * (m + 1)]
     P = self.params[10 + n + m + p + q + 4 + (n + 1) * (m + 1):-4]
     w = np.resize(w, (m + 1, n + 1, 1))
     w = w.transpose((1, 0, 2))
     P = np.resize(P, (m + 1, n + 1, 3))
     P = P.transpose((1, 0, 2))
     P *= w
     Pw = np.concatenate((P, w), axis=2)
     s = surface.Surface(surface.ControlNet(Pw=Pw), (p, q), (U, V))
     objs.append(s)
Пример #10
0
def sphere(N, edge_length, radius, scaling=1.0):
    """
    Creates a 2D Hertzian contact domain, a half sphere embedded in a plane.
    >>> r = 1.0
    >>> s = sphere(100, 1., r)
    >>> np.isclose(np.max(s.h), r, rtol=1.0E-4)
    True
    """
    x = np.linspace(-edge_length / 2.0, edge_length / 2.0, N)
    XX, YY = np.meshgrid(x, x)
    r = np.sqrt(XX * XX + YY * YY)
    h = np.zeros(r.shape)
    h[r <= radius] = np.sqrt(radius**2 - r[r <= radius]**2) * scaling
    dxy = edge_length / float(N)
    s = bs.Surface(h, dxy)
    return s
Пример #11
0
		pass
	else:
		m = m + 1
		number = m
		radius = i[1]
		thickness = i[2]
		if i[3] == '':
			index = 0
		else:
			index = 1.5
		STO = False
		if len(i) == 5:
			STO = True
		s = surface.Surface(number = number,
								radius = radius,
								thickness = i[2], 
								index = index,
								STO = STO)
		Surface_list.append(s)

for j in range(len(Surface_list)):
	print Surface_list[j].number,' ',Surface_list[j].radius,' ',Surface_list[j].thickness,Surface_list[j].STO
	
	
	
	
	
	
	
	
	
Пример #12
0
# define rays
l1 = np.linspace(-5, 5, 10)
Pos1 = []
for i in l1:
    for j in l1:
        if i**2 + j**2 < 25:
            Pos1.append([i, j, 0])
KLM = []
for i in Pos1:
    KLM.append([0, 0, 1])

# define surface
surface1 = surface.Surface(number=1,
                           radius=10000000,
                           thickness=10,
                           index=1,
                           STO=0)  #object
surface2 = surface.Surface(number=2, radius=20, thickness=40, index=2,
                           STO=0)  #surface i
surface3 = surface.Surface(number=3,
                           radius=10000000,
                           thickness=0,
                           index=1,
                           STO=0)  #image

raylist1 = []
raylist2 = []

for pos, klm in zip(Pos1, KLM):
    ray1 = field.Field(Pos=pos, KLM=klm)
Пример #13
0
 def addSurface(self):
     # add a shape surface
     s = surface.Surface()
     self.verticalLayout.addWidget(s)
     return s
Пример #14
0
    def extract(self, u, di):
        ''' Extract an isoparametric Surface from the Volume.

        Parameters
        ----------
        u = the parameter value at which to extract the Surface
        di = the parametric direction in which to extract the Surface
             (0, 1 or 2)

        Returns
        -------
        Surface = the extracted Surface

        '''

        n, p, U, m, q, V, l, r, W, Pw = self.var()
        u = knot.clean_knot(u)
        if di == 0:
            if u == U[0]:
                Pwc = Pw[0, :, :]
            elif u == U[-1]:
                Pwc = Pw[-1, :, :]
            else:
                k, s = basis.find_span_mult(n, p, U, u)
                rr = p - s
                if rr > 0:
                    U, V, W, Pw = \
                            volume_knot_ins(n, p, U, m, q, V, l, r, W,
                                            Pw, u, k, s, rr, 0)
                Pwc = Pw[k - s, :, :]
            p, q = q, r
            U, V = V, W
        elif di == 1:
            if u == V[0]:
                Pwc = Pw[:, 0, :]
            elif u == V[-1]:
                Pwc = Pw[:, -1, :]
            else:
                k, s = basis.find_span_mult(m, q, V, u)
                rr = q - s
                if rr > 0:
                    U, V, W, Pw = \
                            volume_knot_ins(n, p, U, m, q, V, l, r, W,
                                            Pw, u, k, s, rr, 1)
                Pwc = Pw[:, k - s, :]
            Pwc = np.transpose(Pwc, (1, 0, 2))
            p, q = r, p
            U, V = W, U
        elif di == 2:
            if u == W[0]:
                Pwc = Pw[:, :, 0]
            elif u == W[-1]:
                Pwc = Pw[:, :, -1]
            else:
                k, s = basis.find_span_mult(l, r, W, u)
                rr = r - s
                if rr > 0:
                    U, V, W, Pw = \
                            volume_knot_ins(n, p, U, m, q, V, l, r, W,
                                            Pw, u, k, s, rr, 2)
                Pwc = Pw[:, :, k - s]
        return surface.Surface(surface.ControlNet(Pw=Pwc), (p, q), (U, V))
Пример #15
0
def main():
    surfaceobj = surface.Surface(filename, 5, 5, 5, 5)
    rectobj = surfaceobj.getRect()
    print(rectobj)