示例#1
0
def prepare_scoreboardeffect(scale):
    image = Image.new('RGBA', (int(1366 * scale), int(768 * scale)))
    draw = ImageDraw.Draw(image)
    alpha = 0
    width = 1366 * scale
    height = 0
    x = 0
    y = 768 * scale * 0.5
    speed = 5 * scale
    speedalpha = 0
    for i in range(50):
        draw.ellipse((x, y, x + width, y + height),
                     fill=(255, 255, 255, int(alpha)),
                     outline=(255, 255, 255, int(alpha)))
        alpha = min(220, alpha + speedalpha)
        x += 1.5 * scale
        y -= speed
        width -= 3 * scale
        height += speed * 2
        speed = max(0.00001, speed - 0.75 * scale)
        speedalpha = min(20, speedalpha + 0.05 * scale)

    eclipseeffect = image.crop(
        (int(image.size[0] * 3 / 5), y, image.size[0], y + height))
    eclipseeffect = imageproc.change_size(eclipseeffect, 2.25, 2.5)

    image = Image.new('RGBA', (int(1366 * scale), int(768 * scale)))
    draw = ImageDraw.Draw(image)
    alpha = 0
    width = 1366 * scale
    height = 768 * scale
    x = 0
    y = 0
    speedalpha = 0
    for i in range(50):
        draw.ellipse((x, y, x + width, y + height),
                     fill=(255, 255, 255, int(alpha)),
                     outline=(255, 255, 255, int(alpha)))
        alpha = min(170, alpha + speedalpha)
        x += 1.5 * scale
        y += 0.3 * scale
        width -= 4
        height -= 0.6 * scale
        speedalpha = min(10, speedalpha + 0.15 * scale)
    circleeffect = image.crop(
        (int(image.size[0] * 9 / 10), int(image.size[1] * 2 / 10),
         image.size[0], int(image.size[1] * 8 / 10)))
    circleeffect = imageproc.change_size(circleeffect, 0.5, 0.5)
    return [eclipseeffect, circleeffect]
示例#2
0
    def get_slider_img(self, slidertype, ps, pixel_length):
        ps = self.convert(ps)
        slider_c = getclass(slidertype, ps, pixel_length * self.scale)
        curve_pos = np.int32(slider_c.pos)
        min_x, min_y, max_x, max_y = self.get_min_max(
            curve_pos)  # start y end y start x end x

        self.draw(curve_pos)

        # crop useless part of image
        up_y_corner = max(0, int(min_y - self.extended))
        left_x_corner = max(0, int(min_x - self.extended))
        down_y_corner = min(self.img.shape[0], int(max_y + self.extended))
        right_x_corner = min(self.img.shape[1], int(max_x + self.extended))

        img = self.pbuffer.crop(
            (left_x_corner, up_y_corner, right_x_corner, down_y_corner))
        if self.coef != 1:
            img = imageproc.change_size(img, 1 / self.coef, 1 / self.coef)

        self.img[up_y_corner:down_y_corner,
                 left_x_corner:right_x_corner] = 0  # reset

        x_offset = int((curve_pos[0][0] - left_x_corner) / self.coef)
        y_offset = int((curve_pos[0][1] - up_y_corner) / self.coef)

        return img, x_offset, y_offset
示例#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))
示例#4
0
def list_resize(img, start, end, step):
    outputs = []
    x = start
    for i in img:
        im = imageproc.change_size(i, x, x)
        outputs.append(im)
        x += step
    return outputs
示例#5
0
def prepare_accuracy(scorenumbers):
    """
	:param scorenumbers: Scorenumber
	:return: int, [PIL.Image]
	"""
    score_images = {}
    y = int(scorenumbers.score_images[0].img.size[1])
    for index, img in enumerate(scorenumbers.score_images):
        imgacc = imageproc.change_size(img.img, 0.5, 0.5)
        score_images[index] = imgacc
    imgacc = imageproc.change_size(scorenumbers.score_percent.img, 0.6, 0.6)
    score_images["%"] = imgacc

    imgacc = imageproc.change_size(scorenumbers.score_dot.img, 0.5, 0.5)
    score_images["."] = imgacc

    return score_images, y
示例#6
0
def img_resize(img, start, end, step):
    outputs = []
    if not step:
        step = 1
    for x in np.arange(start, end, step):
        im = imageproc.change_size(img, x, x)
        outputs.append(im)
    return outputs
示例#7
0
def img_resize_(img: Image, start: float, end: float, delta: float,
                duration: float, easing: easings):
    res = []

    for time in np.arange(0, duration, delta):
        size_val = easing(time, start, end, duration)
        res.append(imageproc.change_size(img, size_val, size_val))

    return res
示例#8
0
def prepare_scorecounter(scorenumber):
    """
	:param scorenumber: ScoreNumber
	:return: [PIL.Image]
	"""
    img = []
    for image in scorenumber.score_images:
        imgscore = imageproc.change_size(image.img, 0.87, 0.87)
        img.append(imgscore)
    return img
示例#9
0
def list_resize_(imgs: [Image], start: float, end: float, duration: float,
                 easing: easings):
    res = []
    delta = duration / len(imgs)
    cur_time = 0

    for img in imgs:
        size_val = easing(cur_time, start, end, duration)
        res.append(imageproc.change_size(img, size_val, size_val))
        cur_time += delta

    return res
示例#10
0
 def set_strain_graph(self, filename):
     if (self.settings.settings["Enable Strain Graph"]):
         strain_graph = Image.open(filename).convert("RGBA")
         self.graph = imageproc.change_size(strain_graph, self.scale,
                                            self.scale)
         self.graph_np = np.array(self.graph)
         self.graph = Image.frombuffer("RGBA", self.graph.size,
                                       self.graph_np, "raw", "RGBA", 0, 1)
         self.graph.readonly = False
         self.graph_mask = self.graph_np[:, :, -1] > 0
         self.width, self.height = self.graph.size
         return True
示例#11
0
    def change_size(self, scale_row, scale_col):
        """
		When using this method, the original image size will be used
		:param scale_row: float
		:param scale_col: float
		:return:
		"""
        self.img = imageproc.change_size(self.img,
                                         scale_row,
                                         scale_col,
                                         rows=self.orig_rows,
                                         cols=self.orig_cols)
示例#12
0
def prepare_spinbonus(scorenumber):
    score_frames = []
    for image in scorenumber.score_images:
        score_frames.append([])
        size = 2.5
        for x in range(15, 5, -1):
            img = imageproc.change_size(image.img,
                                        size,
                                        size,
                                        rows=image.orig_rows,
                                        cols=image.orig_cols)
            score_frames[-1].append(imageproc.newalpha(img, x / 15))
            size -= 0.1
    return score_frames
示例#13
0
def prepare_rankingscorecounter(scorenumber):
    """
	:param scorenumber: ScoreNumber
	:return: [PIL.Image]
	"""
    img = {}
    hitresultimg = {}
    c = 0
    for image in scorenumber.score_images:
        imgscore = imageproc.change_size(image.img, 1.2999, 1.2999)
        img[c] = imgscore

        hitresultimg[c] = image.img
        c += 1
    imgscore = imageproc.change_size(scorenumber.score_dot.img, 1, 1)
    hitresultimg["."] = imgscore

    imgscore = imageproc.change_size(scorenumber.combo_x.img, 1, 1)
    hitresultimg["x"] = imgscore

    imgscore = imageproc.change_size(scorenumber.score_percent.img, 1, 1)
    hitresultimg["%"] = imgscore
    return img, hitresultimg
示例#14
0
def prepare_approach(scale, time_preempt, settings):
    """
	:param settings:
	:param scale: float
	:param time_preempt: the time the circle is on screen
	:return: [PIL.Image]
	"""
    img = YImage(approachcircle, settings).img
    approach_frames = []

    s = 3.5
    interval = settings.timeframe / settings.fps
    for time_left in np.arange(time_preempt, 0, -interval):
        s -= 2.5 * interval / time_preempt
        p = imageproc.change_size(img, s * scale, s * scale)
        approach_frames.append(p)
    return approach_frames
示例#15
0
def overlayhitcircle(overlay, circle, color, scale):

    color_circle = imageproc.add_color(circle, color)

    maxwidth = max(color_circle.size[0], overlay.size[0])
    maxheight = max(color_circle.size[1], overlay.size[1])

    background = Image.new("RGBA", (maxwidth, maxheight))
    background.paste(color_circle,
                     (maxwidth // 2 - color_circle.size[0] // 2,
                      maxheight // 2 - color_circle.size[1] // 2))
    color_circle = background

    overlay_img = overlay.copy()

    x1 = color_circle.size[0] // 2
    y1 = color_circle.size[1] // 2

    imageproc.add(overlay_img, color_circle, x1, y1, channel=4)
    return imageproc.change_size(color_circle, scale, scale)
示例#16
0
def prepare_background(backgroundname, settings):
    """
	:param backgroundname: string
	:return: PIL.Image
	"""
    try:
        img = Image.open(backgroundname).convert("RGBA")
    except Exception as e:
        logger.error(repr(e))
        img = Image.open(os.path.join(settings.path,
                                      "res/bg.png")).convert("RGBA")

    width = settings.width
    height = settings.height
    ratiow = width / height
    ratioh = height / width

    w = min(img.size[0], int(img.size[1] * ratiow))
    h = min(img.size[1], int(img.size[0] * ratioh))
    x, y = (img.size[0] - w) // 2, (img.size[1] - h) // 2
    img = img.crop((x, y, x + w, y + h))

    scale = width / w
    img = imageproc.change_size(img, scale, scale)
    imgs = [Image.new("RGBA", (1, 1))]

    dim = max(0, min(100, (100 - settings.settings["Background dim"]))) * 2.55
    color = np.array([dim, dim, dim])
    interval = int(1000 / 45)
    c_interval = max(0, (settings.settings["Background dim"] - 50) * 2.55 /
                     interval)
    color[:] = color[:] - c_interval
    for x in range(interval):
        color[:] = color[:] + c_interval
        a = imageproc.add_color(img, color)
        imgs.append(a)
    return imgs
示例#17
0
def prepare_scoreboardscore(scale, settings):
    """
	:param settings:
	:param path: string of path, without filename
	:param scale: float
	:param color: tuple(R, G, B)
	:return: [PIL.Image]
	"""

    scale = scale * 0.8

    numbers_animation = []
    for x in range(12):
        if x == 10:
            x = "x"
        if x == 11:
            x = "dot"
        number = YImage(scoreentry + str(x), settings, scale)

        if number.imgfrom == ImageFrom.BLANK:
            img = Image.open(
                os.path.join(settings.path, "res",
                             scoreentry + str(x) + "@2x.png"))
            img = imageproc.change_size(img, scale * 0.5, scale * 0.5)
        else:
            img = number.img

        numbers_animation.append(img)
    combo_number = imageproc.change_sizes(numbers_animation, 0.9, 0.9)
    combo_number = imageproc.add_color_s(combo_number, [200, 255, 255])
    combo_number = scorelist_to_dict(combo_number)

    bigger_numbers_animation = imageproc.change_sizes(numbers_animation, 2, 2)
    bigger_numbers_animation = scorelist_to_dict(bigger_numbers_animation)

    numbers_animation = scorelist_to_dict(numbers_animation)
    return numbers_animation, bigger_numbers_animation, combo_number