예제 #1
0
def list_fade(img: [Image], start: float, end: float, step: float):
    outputs = []
    x = start
    for i in img:
        im = imageproc.newalpha(i, x)
        outputs.append(im)
        x += step
    return outputs
예제 #2
0
def list_fade(img, start, end, step):
	outputs = []
	x = start
	for i in img:
		im = imageproc.newalpha(i, x)
		outputs.append(im)
		x += step
	return outputs
예제 #3
0
def img_fade_(img: Image, start: float, end: float, delta: float,
              duration: float, easing: easings):
    res = []

    for time in np.arange(0, duration, delta):  # for now
        fade_val = easing(time, start, end, duration)
        res += [imageproc.newalpha(img, fade_val)]

    return res
예제 #4
0
def list_fade_(imgs: [Image], start: float, end: float, duration: float,
               easing: easings):
    res = []
    delta = duration / len(imgs)
    cur_time = 0

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

    return res
예제 #5
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
예제 #6
0
def overlayapproach(circle, approach, alpha):

    maxwidth = max(approach.size[0], circle.size[0])
    maxheight = max(approach.size[1], circle.size[1])

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

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

    imageproc.add(circle, approach, x1, y1, channel=4)
    return imageproc.newalpha(approach, alpha / 100)
예제 #7
0
def prepare_text(texts, size, color, settings, alpha=1, fontpath=""):
    if fontpath == "":
        fontpath = os.path.join(settings.path, "res/Aller_Rg.ttf")
    size = int(size)
    try:
        font = ImageFont.truetype(fontpath, size=size)
    except Exception as e:
        font = ImageFont.truetype(os.path.join(settings.path,
                                               "res/Aller_Rg.ttf"),
                                  size=size)
        logger.error(repr(e))

    img = Image.new("RGBA", (settings.width, settings.height))
    imgdraw = ImageDraw.Draw(img)
    imgs = {}
    for text in texts:
        img.paste((0, 0, 0, 0), (0, 0, img.size[0], img.size[1]))
        s = imgdraw.textsize(text, font=font)
        imgdraw.text((0, 0), text, color, font=font, spacing=size)
        imgs[text] = imageproc.newalpha(img.crop((0, 0, s[0], s[1])), alpha)

    return imgs
예제 #8
0
def prepare_spinner(scale, settings):
    scale = scale * 1.3 * 0.5
    spinner_images = {}
    n = [
        spinnercircle, spinnerbackground, spinnermiddle, spinnermiddle2,
        spinnerspin, spinnermetre, spinnerbottom, spinnerrpm
    ]

    spinv2 = False
    for img in n:
        yimage = YImage(img, settings, scale)
        spinner_images[img] = imageproc.newalpha(yimage.img, 0.75)
        if img == spinnerbackground and yimage.imgfrom == ImageFrom.BLANK:
            spinv2 = True

    if spinv2:
        spinner_images[spinnerbackground] = spinner_images[spinnermiddle]

        maxwidth = max(spinner_images[spinnerbottom].size[0],
                       spinner_images[spinnermiddle2].size[0])
        maxheight = max(spinner_images[spinnerbottom].size[1],
                        spinner_images[spinnermiddle2].size[1])
        circle = Image.new("RGBA", (maxwidth, maxheight))
        imageproc.add(spinner_images[spinnermiddle2],
                      circle,
                      circle.size[0] / 2,
                      circle.size[1] / 2,
                      channel=4)
        imageproc.add(spinner_images[spinnerbottom],
                      circle,
                      circle.size[0] / 2,
                      circle.size[1] / 2,
                      channel=4)
        spinner_images[spinnercircle] = circle

        spinner_images[spinnermetre] = Image.new("RGBA", (1, 1))

    return spinner_images
예제 #9
0
def img_fade(img, start, end, step):
	outputs = []
	for x in np.arange(start, end, step):
		im = imageproc.newalpha(img, x)
		outputs.append(im)
	return outputs
예제 #10
0
def prepare_rankingreplay(scale, settings):
    img = YImage(rankingreplay, settings, scale).img
    img = imageproc.newalpha(img, 0.4)

    return [img]
예제 #11
0
def prepare_circle(diff, scale, settings, hd):
    # prepare every single frame before entering the big loop, this will save us a ton of time since we don't need
    # to overlap number, circle overlay and approach circle every single time.

    opacity_interval, time_preempt, fade_in = calculate_ar(
        diff["ApproachRate"], settings)

    cs = (54.4 - 4.48 * diff["CircleSize"]) * scale
    radius_scale = cs * overlay_scale * 2 / default_size

    circle, c_overlay, slider, s_overlay = load(settings)
    if not hd:
        approach_frames = prepare_approach(radius_scale, time_preempt,
                                           settings)

    fadeout = [[], []]  # circle, slider
    circle_frames = []  # [color][number][alpha]
    slidercircle_frames = []  # [color][number][alpha]
    alphas = []

    for c in range(1, settings.skin_ini.colours["ComboNumber"] + 1):
        color = settings.skin_ini.colours["Combo" + str(c)]

        orig_circle = overlayhitcircle(c_overlay, circle, color, radius_scale)

        if not hd:
            fadeout[0].append(prepare_fadeout(orig_circle, settings))
        else:
            fadeout[0].append([Image.new("RGBA", (1, 1))])

        orig_slider = overlayhitcircle(s_overlay, slider, color, radius_scale)

        if not hd:
            fadeout[1].append(prepare_fadeout(orig_slider, settings))
        else:
            fadeout[1].append([Image.new("RGBA", (1, 1))])

        alpha = 0  # alpha for fadein
        circle_frames.append([])
        slidercircle_frames.append([])
        if not hd:

            # we also overlay approach circle to circle to avoid multiple add_to_frame call
            for i in range(len(approach_frames)):
                approach_circle = imageproc.add_color(approach_frames[i],
                                                      color)
                approach_slider = approach_circle.copy()

                circle_frames[-1].append(
                    overlayapproach(orig_circle, approach_circle, alpha))
                slidercircle_frames[-1].append(
                    overlayapproach(orig_slider, approach_slider, alpha))

                alphas.append(alpha)
                alpha = min(100, alpha + opacity_interval)
            # for late tapping
            slidercircle_frames[-1].append(orig_slider)
            circle_frames[-1].append(orig_circle)
            alphas.append(alpha)

        else:
            # source: https://github.com/ppy/osu/blob/4cb57f8205edf5ed7b7da076325ba76ec9cc3039/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs#L23
            interval = settings.timeframe / settings.fps
            fade_in = time_preempt * 0.4
            fade_in_interval = 100 * interval / fade_in

            ii = fade_in_interval

            fade_out = time_preempt * 0.3
            fade_out_interval = 100 * interval / fade_out

            #interval = 1 if not interval else interval
            for i in np.arange(time_preempt, 0, -interval):
                if alpha != 0:
                    circle_frames[-1].append(newalpha(orig_circle,
                                                      alpha / 100))
                    slidercircle_frames[-1].append(
                        newalpha(orig_slider, alpha / 100))
                else:
                    circle_frames[-1].append(Image.new("RGBA", (1, 1)))
                    slidercircle_frames[-1].append(Image.new("RGBA", (1, 1)))

                if alpha == 100:
                    ii = -fade_out_interval

                alphas.append(alpha)
                alpha = max(0, min(100, alpha + ii))

        logger.debug("done")

    return slidercircle_frames, circle_frames, fadeout, alphas