mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-05 19:23:45 +08:00
修正srmr绘图错误 (#29)
* 修正srmr绘图错误
* 🚨 `pre-commit-ci`修复格式错误
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
c82ba74e56
commit
cd07941c22
@ -11,6 +11,7 @@ from ..utils.api import get_sqla
|
||||
from ..utils.mys_api import mys_api
|
||||
from ..utils.image.convert import convert_img
|
||||
from ..sruid_utils.api.mys.models import Expedition
|
||||
from ..utils.image.image_tools import get_simple_bg
|
||||
from ..utils.fonts.starrail_fonts import (
|
||||
sr_font_22,
|
||||
sr_font_24,
|
||||
@ -145,21 +146,22 @@ async def draw_resin_img(sr_uid: str) -> Image.Image:
|
||||
# 获取数据
|
||||
daily_data = await mys_api.get_daily_data(sr_uid)
|
||||
|
||||
img = note_bg.copy()
|
||||
img = await get_simple_bg(based_w, based_h)
|
||||
img.paste(white_overlay, (0, 0), white_overlay)
|
||||
|
||||
if isinstance(daily_data, int):
|
||||
img_draw = ImageDraw.Draw(img)
|
||||
img.paste(warn_pic, (0, 0), warn_pic)
|
||||
# 写UID
|
||||
img_draw.text(
|
||||
(250, 553),
|
||||
(350, 680),
|
||||
f'UID{sr_uid}',
|
||||
font=sr_font_26,
|
||||
fill=first_color,
|
||||
anchor='mm',
|
||||
)
|
||||
img_draw.text(
|
||||
(250, 518),
|
||||
(350, 650),
|
||||
f'错误码 {daily_data}',
|
||||
font=sr_font_26,
|
||||
fill=red_color,
|
||||
@ -185,7 +187,7 @@ async def draw_resin_img(sr_uid: str) -> Image.Image:
|
||||
daily_data['stamina_recover_time']
|
||||
)
|
||||
|
||||
img_draw = ImageDraw.Draw(img)
|
||||
img.paste(note_bg, (0, 0), note_bg)
|
||||
|
||||
# 派遣
|
||||
task_task = []
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 130 KiB |
@ -106,6 +106,23 @@ async def get_color_bg(
|
||||
return img
|
||||
|
||||
|
||||
async def get_simple_bg(
|
||||
based_w: int, based_h: int, image: Union[str, None, Image.Image] = None
|
||||
) -> Image.Image:
|
||||
if image:
|
||||
if isinstance(image, str):
|
||||
edit_bg = Image.open(BytesIO(get(image).content)).convert('RGBA')
|
||||
elif isinstance(image, Image.Image):
|
||||
edit_bg = image.convert('RGBA')
|
||||
else:
|
||||
bg_path = random.choice(list(NM_BG_PATH.iterdir()))
|
||||
edit_bg = Image.open(bg_path).convert('RGBA')
|
||||
|
||||
# 确定图片的长宽
|
||||
bg_img = crop_center_img(edit_bg, based_w, based_h)
|
||||
return bg_img
|
||||
|
||||
|
||||
def crop_center_img(
|
||||
img: Image.Image, based_w: int, based_h: int
|
||||
) -> Image.Image:
|
||||
|
Loading…
x
Reference in New Issue
Block a user