Example #1
0
    def __init__(self, frames, replayinfo, meta, settings):
        dummy = [Image.new("RGBA", (1, 1))]
        super().__init__(dummy, settings=settings)
        self.replayinfo = replayinfo
        self.artist = meta["Artist"]
        self.beatmapname = meta["Title"]
        self.mapper = meta["Creator"]
        self.diff = meta["Version"]
        self.player = replayinfo.player_name

        timestamp = self.set_timezone(replayinfo)
        self.date = str(timestamp.replace(microsecond=0))
        self.date = self.date.replace("-", "/")

        self.rankingtitle = frames[0]

        titleimg = prepare_text(
            ["{} - {} [{}]".format(self.artist, self.beatmapname, self.diff)],
            30 * self.settings.scale, (255, 255, 255, 255), settings)
        creatorimg = prepare_text(["Beatmap by {}".format(self.mapper)],
                                  20 * self.settings.scale,
                                  (255, 255, 255, 255), settings)
        playerimg = prepare_text(
            ["Played by {} on {}".format(self.player, self.date)],
            20 * self.settings.scale, (255, 255, 255, 255), settings)

        self.textimgs = {**titleimg, **creatorimg, **playerimg}
Example #2
0
    def __init__(self, frames, scorenetryframes, effectframes, replay_info,
                 meta, maphash, settings):
        FrameObject.__init__(self, frames, settings=settings)

        self.score = scorenetryframes[0]
        self.rank = scorenetryframes[1]
        self.combo = scorenetryframes[2]

        self.effecteclipse = effectframes[0]
        self.effectcircle = effectframes[1]
        self.effectx, self.effecty, self.effectalpha = [], [], []

        self.scoreboards = []
        self.posboards = []
        self.alphaboards = None
        self.origposboards = []
        self.playerboard = None
        self.curscore = 0
        self.maxcombo = 0
        self.oldrankid = None
        self.falling = False
        self.removeone = 0

        self.nboard = 6
        self.height = (660 - 313) / self.nboard * settings.scale
        self.beatmaphash = replay_info.beatmap_hash
        self.playerscore = replay_info.score
        self.playername = replay_info.player_name
        self.beatmapid = self.getmapid(meta, maphash)
        self.frame_interval = self.settings.timeframe / self.settings.fps

        self.scoresid = []
        self.getscores()

        if len(self.scoreboards) > 50 - self.removeone:
            _, _ = self.sortscore(000)
            self.scoreboards = self.scoreboards[:50 - self.removeone]
        self.scoreboards.append(
            BoardInfo("0", "0", self.curscore, self.maxcombo,
                      replay_info.player_name, None, None, None, -1))
        self.shows = max(0, len(self.scoreboards) - self.nboard + 1)
        _, self.currank = self.sortscore()

        self.setuppos()

        self.animate = False

        playernames = [x.playername for x in self.scoreboards]
        self.nameimg = prepare_text(playernames, 18 * self.settings.scale,
                                    (255, 255, 255, 255), self.settings, 0.5)
        playertext = prepare_text([self.playername], 18 * self.settings.scale,
                                  (255, 255, 255, 255), self.settings, 1)

        self.nameimg[self.playername] = playertext[self.playername]
Example #3
0
    def loadimg(self):
        char = [str(x) for x in range(10)]
        char.append(".")
        char.append(" ")
        frames = prepare_text(
            char,
            self.countersettings[self.prefix + "Size"] * self.settings.scale,
            self.countersettings[self.prefix + "Rgb"],
            self.settings,
            alpha=self.countersettings[self.prefix + "Alpha"],
            fontpath=self.countersettings[self.prefix + "Font"])

        for i in frames:
            self.frames[int(i) if i.isdigit() else i] = frames[i]

        try:
            self.background = Image.open(
                self.countersettings[self.prefix +
                                     "Background"]).convert("RGBA")
            scale = self.settings.scale * self.countersettings[self.prefix +
                                                               "Size"] / 20
            self.background = imageproc.change_size(self.background, scale,
                                                    scale)
        except Exception as e:
            logger.error(repr(e))
            self.background = Image.new("RGBA", (1, 1))
Example #4
0
def prepare_rankingur(settings, ur):
	"""
	:param settings: Settings
	:param ur: [error -, error +, ur]
	:return:
	"""
	error_ = "{:.2f}".format(ur[0])
	error = "{:.2f}".format(ur[1])
	ur = "{:.2f}".format(ur[2])
	text = ["Accuracy:", f"Error {error_}ms - {error}ms avg", f"Unstable Rate: {ur}"]
	scale = settings.scale * 1.3
	width = int(scale * 350)
	height = int(width * 9 / 16 * len(text)/6)

	image = Image.new("RGBA", (width, height))
	d = ImageDraw(image)
	rounded_rectangle(d, ((0, 0), (width, height)), 20, fill=(255, 255, 255, 200))
	rounded_rectangle(d, ((2, 2), (width - 2, height - 2)), 15, fill=(0, 0, 0, 200))

	texti = prepare_text(text, scale * 20, (255, 255, 255), settings)
	y = height * 0.025
	for t in texti:
		imageproc.add(texti[t], image, width * 0.01, y, topleft=True)
		y += texti[t].size[1] + 5 * settings.scale

	image = image.resize((width // 2, height // 2))
	return [image]