Пример #1
0
    def __init__(self, size, tilesize=100, message_font=None, glyph_font=None, margin=50, circle=False, tile_cls=None):
        Board.__init__(self, size, tile_cls)

        font.init()
        message_font      = message_font or (None, 60)
        glyph_font        = glyph_font or (None, 70)
        self.message_font = font.Font(message_font[0], message_font[1])
        self.glyph_font   = font.Font(glyph_font[0], glyph_font[1])
        n                 = tilesize + 1
        self.margin       = margin
        self.scr          = display.set_mode((size[0]*n + margin*2, size[1]*n + margin*2))
        self.scr.fill(white)
        self.sfc = Surface(self.scr.get_size())
        self.sfc = self.sfc.convert()
        self.sfc.fill(white)

        self.scr.blit(self.sfc, (0,0))
        self.tilesize  = tilesize
        self.circle    = circle
        self.tile_locs = [[ (iround(margin+x+tilesize/2) , iround(margin+y+tilesize/2))
                              for x in range(0, size[0]*n, n)]
                              for y in range(0, size[1]*n, n)]
        for tile in self:
            self.mkgui_tile(tile.loc)

        self.scr.blit(self.sfc, (0,0))
        display.flip()
Пример #2
0
    def center_on(self, item_loc):
        loc        = self.ploc(item_loc)
        halfwidth  = iround(self.vwidth / 2)
        halfheight = iround(self.vheight / 2)

        if self.viswrap:
            x = Loop(range(self.width), index=loc.x)
            y = Loop(range(self.height), index=loc.y)
            x = x.prev(halfwidth)
            y = y.prev(halfheight)
        else:
            x, y = loc.x - self.halfwidth, loc.y - self.halfheight
            x, y = max(0, x), max(0, y)

        writeln(self.vtopleft, loc)
        self.vtopleft = Loc(x, y)
        writeln(self.vtopleft); writeln()
Пример #3
0
    def mkgui_tile(self, loc, only_clear=False):
        """ Redraw the gui tile or just clear the tile.

            only_clear: use to clear 'unmovable' tiles; if False, clear and then redraw tile
        """
        loc = self.resolve_loc(loc)
        ts = self.tilesize
        if self.circle:
            gfxdraw.filled_circle(self.sfc, loc[0], loc[1], iround(ts/2), white)
            if not only_clear:
                gfxdraw.aacircle(self.sfc, loc[0], loc[1], iround(ts/2-4), gray)
        else:
            r = center_square(loc, ts)
            draw.rect(self.sfc, white, r, 0)
            if not only_clear:
                gfxdraw.rectangle(self.sfc, r, gray)
        self.scr.blit(self.sfc, (0,0))
Пример #4
0
 def match_middle(src, dst, subList):
     if len(subList) < 10:
         return None
     for i in range(10):
         sub = subList[iround((len(subList) / 2.0) - 5 + i)]
         res = autoSyncTools.match(src, dst, int(sub.startTime),
                                   int(sub.stopTime), 0)
         if not (res is None):
             return res
Пример #5
0
    def process_wav(self):
        os.rename(self.audioFile + '.raw', self.audioFile)
        audioSize = os.stat(self.audioFile).st_size
        audioDuration = iround((1000 * audioSize) / self.audioRate)
        audioDuration = ceil(audioDuration / 10) * 10  # VSS SYNC
        if audioSize <= 0:
            return
        samplesPerDataPoint = self.audioRate / 100
        dataPoints = ceil(audioSize / samplesPerDataPoint)
        samplesPerDataPoint = int(samplesPerDataPoint)

        with open(self.audioFile, 'rb') as f:

            hiAudio = []
            lowAudio = []
            dp_div = iround(dataPoints / 10)

            for point in range(iround(dataPoints)):
                tmpData = bytearray(f.read(samplesPerDataPoint))
                if len(tmpData) == 0:
                    break

                hiAudio.append(abs(max(tmpData) - 128))
                lowAudio.append(-abs(min(tmpData) - 128))

                if point % dp_div == 0:
                    self.set_progress(0.5 + (point // dataPoints) // 2)
                    self.process_messages()

        maxv = max(hiAudio)
        minv = min(lowAudio)
        hiAudio = numarray(hiAudio) / maxv
        lowAudio = numarray(lowAudio) / minv

        self.set_progress(1)
        self.process_messages()

        with open(self.audioFile, 'wb') as f:
            savez(f, hiAudio, lowAudio, numarray([audioDuration]))
Пример #6
0
 def middle(self):
     return iround(self.width / 2) - 1, iround(self.height / 2) - 1
Пример #7
0
    def get_badges(self, level):
        level = iround(level*badge_modifier)
        lines = self.advanced_badges(level) + [ self.basic_badges(level) ]
        lines = [space.join(line) for line in lines]

        return nl.join(l.center(16) for l in lines if l)
Пример #8
0
Файл: versi.py Проект: Voder/PBE
 def middle(self):
     return iround(self.width/2) - 1, iround(self.height/2) - 1