MCPcopy Create free account
hub / github.com/Loping151/RoverSign / create_gradient_background

Function create_gradient_background

RoverSign/roversign_sign/main.py:577–601  ·  view source on GitHub ↗

使用 PIL 创建渐变背景 start_color: 起始颜色,如 (230, 230, 255) 浅蓝 end_color: 结束颜色,默认白色

(width, height, start_color, end_color=(255, 255, 255))

Source from the content-addressed store, hash-verified

575
576 # 签到失败
577 logger.error(f"[库洛签到·战双签到] 签到失败: code={sign_in_res.code}, msg={sign_in_res.msg}, data={sign_in_res.data}")
578 return f"签到失败:{sign_in_res.msg}"
579
580
581def create_gradient_background(width, height, start_color, end_color=(255, 255, 255)):
582 """
583 使用 PIL 创建渐变背景
584 start_color: 起始颜色,如 (230, 230, 255) 浅蓝
585 end_color: 结束颜色,默认白色
586 """
587 # 创建新图像
588 image = Image.new("RGB", (width, height))
589
590 for y in range(height):
591 # 计算当前行的颜色比例
592 ratio = y / height
593
594 # 计算当前行的 RGB 值
595 r = int(end_color[0] * ratio + start_color[0] * (1 - ratio))
596 g = int(end_color[1] * ratio + start_color[1] * (1 - ratio))
597 b = int(end_color[2] * ratio + start_color[2] * (1 - ratio))
598
599 # 创建当前行的颜色
600 line_color = (r, g, b)
601 # 绘制当前行
602 for x in range(width):
603 image.putpixel((x, y), line_color)
604

Callers 1

create_sign_info_imageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected