예제 #1
0
def proc_perlins(m):
    matrix = m
    data['img_name'] = 'perlins'
    n1 = noise.Noise(2,
                     octaves=var['octaves']['var'],
                     tile=(var['density']['var'], var['density']['var']),
                     unbias=True,
                     seed=8675309)
    n2 = noise.Noise(2,
                     octaves=var['octaves']['var'],
                     tile=(var['density']['var'], var['density']['var']),
                     unbias=True,
                     seed=var['seed']['var'])
    for y in range(var['height']['var']):
        for x in range(var['width']['var']):
            index = (y * var['width']['var']) + x

            mod1 = n1.get_plain_noise(x / (var['scale']['var'] * .1),
                                      y / (var['scale']['var'] * .1))
            mod2 = n2.get_plain_noise(x / (var['pack']['var'] * .1),
                                      y / (var['pack']['var'] * .1))

            R = int(var['r']['var'] * (mod1 * (var['strength']['var'] * .1)))
            G = int(var['g']['var'] * (mod1 * (var['strength']['var'] * .1)))
            B = int(var['b']['var'] * (mod1 * (var['strength']['var'] * .1)))

            r = int(var['R']['var'] * (mod2 * (var['texture']['var'] * .1)))
            g = int(var['G']['var'] * (mod2 * (var['texture']['var'] * .1)))
            b = int(var['B']['var'] * (mod2 * (var['texture']['var'] * .1)))

            matrix[index] = (data['blnd'][var['blend']['var']]((R, G, B),
                                                               (r, g, b)))

    matrix = overlay_img(matrix)
    return matrix
예제 #2
0
파일: gamemap.py 프로젝트: wty0512/pyDF
 def initMap(self):
     mynoise = noise.Noise(self.mapw, self.maph, self.tw)
     mylist = mynoise.generate()
     # pprint(mylist)
     self.maprect = pygame.Rect(0, 0, self.mapw, self.maph)
     for z in range(self.zlevels):
         for x in range(self.mapw):
             for y in range(self.maph):
                 if self.firstnum(mylist[x][y]) == z:  # tile on the current layer
                     # print "grass"
                     # self.mapdata[z][x][y] = maptile.MapTile(random.randint(1, 4))
                     if self.secondnum(mylist[x][y]) < 7:
                         self.mapdata[z][x][y] = maptile.MapTile(
                             random.randint(1, 4)
                         )
                     else:
                         self.mapdata[z][x][y] = maptile.MapTile(7)
                     # put some ground
                 elif self.firstnum(mylist[x][y]) > z:  # tiles on the layers above
                     # print "dirt"
                     self.mapdata[z][x][y] = maptile.MapTile(0)
                     # dirt
                 elif self.firstnum(mylist[x][y]) < z:  # tiles below the z level
                     # print "nothing"
                     self.mapdata[z][x][y] = maptile.MapTile(5)
                 else:
                     print("x:", x)
                     print(" y:", y)
                     print("z:", z)
                     print("BOMBED")
                     exit()
예제 #3
0
    def __init__(self, log, exp, corr=True):
        #Store passed parameters
        self.exp  = exp
        self.corr = corr

        #Generate classes for calculating
        self.ph   = ph.Physics()
        self.nse  = ns.Noise()
예제 #4
0
    def __init__(self, v):
        self.v = v
        self.offset_x = 0
        self.offset_y = 0

        self.selected_polygon = None
        self.selected_neighbors = None

        self.noise = noise.Noise(0.25, self.v.chunk_database.seed)
예제 #5
0
 def get_noisestats(self, conf):
     nlnm_model = noise.Noise(ratio_nhnm=0., units='ACC')
     prange = []
     data = load_noisepdf(self.channel, conf)
     if data != None:
         for p in conf['periods']:
             prange = Prange(p)
             d = prange.contains_values(data)
             p, nlnm = nlnm_model.calculate(d[:, 0])
             setattr(self, 'mean' + prange.label, np.mean(d[:, 1]))
             setattr(self, 'std' + prange.label, np.mean(d[:, 2]))
             setattr(self, 'skew' + prange.label, np.mean(d[:, 3]))
             setattr(self, 'nlnm' + prange.label,
                     np.mean(d[:, 1]) - np.mean(nlnm))
예제 #6
0
 def estimate_noise(self,
                    method="ROBUST",
                    show=False,
                    timer=False,
                    verbose=False):
     """
     Estimate the noise (currently in one dimension). Saves the
     results to a noise object linked to the data.
     """
     self.noise = noise.Noise(self)
     self.noise.calc_1d(method=method,
                        show=show,
                        timer=timer,
                        verbose=verbose)
    def __init__(self, exp, corr=False):
        #***** Private variables *****
        self.__ph  = phy.Physics()
        self.__nse = nse.Noise()
        self.__exp = exp
        self.__corr = corr

        #Unit conversions
        self.__GHz    = 1.e-09
        self.__mm     = 1.e+03
        self.__pct    = 1.e+02
        self.__pW     = 1.e+12
        self.__aWrtHz = 1.e+18
        self.__uK     = 1.e+06
        self.__uK2    = 1.e-12

        #Directory for writing result tables
        self.__dir = self.__exp.dir+'/TXT/'
예제 #8
0
def proc_perlin(m):
    matrix = m
    data['img_name'] = 'perlin'
    n = noise.Noise(2,
                    octaves=var['octaves']['var'],
                    tile=(var['pack']['var'], var['pack']['var']),
                    unbias=True,
                    seed=var['seed']['var'])
    for y in range(var['height']['var']):
        for x in range(var['width']['var']):
            index = (y * var['width']['var']) + x
            mod = n.get_plain_noise(x / (var['density']['var'] * .1),
                                    y / (var['density']['var'] * .1))
            R = int(var['r']['var'] * (mod * (var['strength']['var'] * .1)))
            G = int(var['g']['var'] * (mod * (var['strength']['var'] * .1)))
            B = int(var['b']['var'] * (mod * (var['strength']['var'] * .1)))
            matrix[index] = data['blnd'][var['blend']['var']](
                (var['R']['var'], var['G']['var'], var['B']['var']), (R, G, B))
    matrix = overlay_img(matrix)
    return matrix
예제 #9
0
 def __init__(self, log, exp, corr=True):
     self.__ph   = ph.Physics()
     self.__nse  = ns.Noise()
     self.__exp  = exp
     self.__corr = corr