44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""PDF扒图图标(Pillow 手绘,白文档+红折角+PDF 红标签,64x64 4x 超采样)。"""
|
|
import os
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
ROOT = r"C:\Users\099978\Documents\SharpDevelop Projects\成套报价软件"
|
|
OUT = os.path.join(ROOT, "成套报价软件", "bin", "Debug", "icons", "pdf-grab.png")
|
|
|
|
S = 4
|
|
RED = (214, 69, 65, 255) # PDF 红
|
|
RED_D = (192, 57, 43, 255) # 深红描边
|
|
INK = (61, 67, 74, 255)
|
|
|
|
img = Image.new("RGBA", (64 * S, 64 * S), (0, 0, 0, 0))
|
|
d = ImageDraw.Draw(img)
|
|
|
|
def P(x, y, w, h, r, fill=None, outline=None, width=0):
|
|
d.rounded_rectangle([x * S, y * S, (x + w) * S, (y + h) * S], radius=r * S,
|
|
fill=fill, outline=outline, width=width * S)
|
|
|
|
def L(pts, color, w):
|
|
d.line([(x * S, y * S) for x, y in pts], fill=color, width=w * S, joint="curve")
|
|
|
|
# 文档(带折角路径)
|
|
doc = [(14, 6), (36, 6), (48, 18), (48, 58), (14, 58)]
|
|
d.polygon([(x * S, y * S) for x, y in doc], fill=(255, 255, 255, 255))
|
|
d.line([(x * S, y * S) for x, y in doc] + [(14 * S, 6 * S)], fill=RED_D, width=3 * S, joint="curve")
|
|
L([(36, 6), (36, 18), (48, 18)], RED_D, 3)
|
|
|
|
# 内容线
|
|
L([(20, 26), (42, 26)], (185, 190, 195, 255), 2)
|
|
L([(20, 33), (42, 33)], (185, 190, 195, 255), 2)
|
|
|
|
# PDF 红标签(左下,压住文档边缘)
|
|
P(6, 38, 36, 18, 3, fill=RED)
|
|
try:
|
|
font = ImageFont.truetype("msyhbd.ttc", 11 * S)
|
|
except Exception:
|
|
font = ImageFont.truetype("arialbd.ttf", 11 * S)
|
|
d.text((24 * S, 47 * S), "PDF", font=font, fill=(255, 255, 255, 255), anchor="mm")
|
|
|
|
img.resize((64, 64), Image.LANCZOS).save(OUT)
|
|
print("pdf-grab.png ->", OUT)
|