import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Rectangle, Circle, Polygon,PathPatch
from matplotlib.text import TextPath
from matplotlib import font_manager
import FontProperties
from matplotlib.path import Path
import matplotlib as mpl
from matplotlib.transforms import Affine2D
import matplotlib.font_manager as fm
plt.rcParams['font.family'] = 'SimSun'
plt.rcParams['axes.unicode_minus'] = False
fig = plt.figure(figsize=(18, 12),dpi=150, facecolor='#faf0e6')
ax = fig.add_subplot(11)
ax.set_xlim(0, 18)
ax.set_ylim(0, 12)
ax.set_aspect('equal')
ax.axis('off')
def draw_cloud_pattern(ax):
for i in range(0, 19, 2):
for j in range(1, 12, 3):
cloud_x = np.array([i,i+0.3, i+0.7, i+1.0, i+0.7, i+0.3, i])
cloud_y = np.array([j,j+0.2, j+0.1, j-0.1, j-0.2, j-0.1, j])
ax.plot(cloud_x, cloud_y,color='#d3d3d3', alpha=0.2,linewidth=0.8)
draw_cloud_pattern(ax)
def draw_jade_slip(ax, x, y, width,height, index, title, content,slip_type):
facecolor = {
'imperial':'#dif0e0',
'title':'#b8e0d2',
'ritual':'#c0e8d5',
'magic':'#a8d8cc',
'bless':'#9cd0c4',
'seal': '#90c8bc',
'charm':'#80c0b0'
}[slip_type]
ax.add_patch(Rectangle((x, y),width, height,facecolor=facecolor,edgecolor='#7a9c96',linewidth=1.5,alpha=0.95, zorder=2))
ax.add_patch(Rectangle((x+0.1,y+0.1), width-0.2, height-0.2,fill=False,edgecolor='#d4af37',linewidth=1.2,linestyle='-', zorder=3))
ax.add_patch(Rectangle((x,y+height*0.85), width,height*0.15,facecolor='#d4af37', alpha=0.25,zorder=3))
ax.text(x + width/2, y +height*0.92, title,fontsize=11, ha='center',va='center',color='#5a3921',fontweight='bold', zorder=4)
trigrams = ["A", "B", "C","D","E","F","G","H"]
ax.text(x+width -0.8,y+height*0.92,trigrams[index-1],fontsize=16,ha='center', va='center', color='#5a3921',zorder=4)
for i in range(3):
ax.plot([x+0.5+i*0.8,x+0.7+i*0.8,x+0.9+i*0.8],[y+height-0.5,y+height-0.3,y+height-0.5], color='#7a9c96', linewidth=1.2,zorder=3)
wave_y=[y+0.4,y+0.2,y+0.3, y+0.1]
for i in range(3):
ax.plot([x+0.3+i*1.2, x+0.7+i*1.2,x+1.1+i*1.2], [wave_y[i%4],wave_y[(i+1)%4],wave_y[(i+2)%4]],color='#7a9c96', linewidth=1,zorder=3)
content_lines =content.split('\n')
line_height =0.7
start_y=y+height*0.75
for i,line in enumerate(content_lines):
if "✷" in line:
ax.text(x+width/2,start_y-i*line_height,line,fontsize=13, ha='center',va='center',color='#b32428', fontweight='bold',bbox=dict(facecolor='#fff9db', alpha=0.4,pad=3,boxstyle='round,pad=0.3'),zorder=4)
else:
ax.text(x+width/2,start_y-i*line_height,line,fontsize=10,ha='center',va='center',
color='#5a3921',fontstyle='italic',bbox=dict(facecolor='#faf0e6', alpha=0.3,pad=1.5,boxstyle='round,pad=0.2'), zorder=4)
def draw_scroll_axis(ax,x,y, height,is_start=True):
ax.add_patch(Rectangle((x-0.2, y),0.4,height,facecolor='#d4af37', edgecolor='#8b4513',linewidth=1.5,zorder=3))
if is_start:
ax.add_patch(Circle((x, y+height+0.3),radius=0.4,facecolor='#d4af37', edgecolor='#8b4513',linewidth=1.5,zorder=4))
head_x=[x,x+0.15,x+0.25, x+0.35,x+0.3,x+0.15,x]
head_y=[y+height+0.5, y+height+0.55,y+height+0.7,y+height+0.65,y+height+0.5,y+height+0.45,y+height+0.5]
ax.add_patch(Polygon(list(zip(head_x,head_y)), facecolor='#e6c35c',edgecolor='#8b4513', linewidth=1,zorder=5))
ax.plot([x+0.1,x+0.15,x+0.2],[y+height+0.6,y+height+0.75,y+height+0.65],color='#8b4513', linewidth=1.5,zorder=5)
for i,pos in enumerate([(x-0.25,y+height-0.5),(x+0.25,y+height-1.5),(x,y+height-2.5),(x-0.2,y+height-3.5),(x+0.2, y+height-4.5),(x-0.15,y+height-5.5),(x+0.15, y+height+0.2)]):
ax.add_patch(Circle(pos, radius=0.08,facecolor='white',edgecolor='#d4af37',linewidth=1, zorder=4))
ax.add_patch(Circle(pos, radius=0.06,facecolor='#fOf8ff', alpha=0.7,zorder=5))
else:
ax.add_patch(Rectangle((x-0.5, y+height+0.1),1.0,0.4,facecolor='#8caba7', dgecolor='#5a3921',linewidth=1.2,zorder=4))
shell_x=[x-0.4,x-0.2,x, x+0.2,x+0.4,x+0.3,x-0.3]
shell_y=[y+height+0.5, y+height+0.6,y+height+0.65,y+height+0.6,y+height+0.5,y+height+0.7,y+height+0.7]
ax.add_patch(Polygon(list(zip(shell_x,shell_y)),facecolor='#5a3921',alpha=0.8, edgecolor='#3a2911',linewidth=1, zorder=5))
hexagon =np.array([[0,0], [-0.1,0.05],[-0.1,0.15],[0,0.2], [0.1,0.15],[0.1,0.05],[0,0]])
for dx,dy in [(0,0),(-0.15,0.1),(0.15,0.1),(0,0.2),(-0.15,0.3), (0.15,0.3)]:
hex_path =Path(hexagon +np.array([x+dx, y+height+0.55+dy]))
ax.add_patch(PathPatch(hex_path, facecolor='#8caba7',edgecolor='#5a3921',linewidth=0.7,zorder=6))
def draw_taoist_symbol(ax,x,y,size,symbol_type):
if symbol_type =="yin yang":
ax.add_patch(Circle((x,y),size/2,facecolor='white',edgecolor='black',linewidth=1, zorder=1))
ax.add_patch(Circle((x, y+size/4),size/4,facecolor='black',edgecolor='black',zorder=2))
ax.add_patch(Circle((x,y-size/4),size/4,facecolor='white', edgecolor='black',zorder=2))
ax.add_patch(Circle((x, y+size/4),size/12,facecolor='white',edgecolor='black',zorder=3))
ax.add_patch(Circle((x,y-size/4),size/12,facecolor='black',edgecolor='black',zorder=3))
theta =np.linspace(-np.pi/2,np.pi/2,50)
curve_x=x+size/4* np.sin(theta)
curve_y=y+size/4* np.cos(theta)
ax.plot(curve_x,curve_y,'k-', linewidth=1.5,zorder=2)
elif symbol_type =="bagua":
trigrams ={
"乾":[True,True,True],
"兑":[True,True,False],
"离":[True,False,True],
"震":[True,False,False],
"巽":[False,True,True],
"坎":[False,True,False],
"艮":[False,False,True],
"坤":[False,False,False]
}
radius =size*0.8
center_x,center_y=x,y
angles =np.linspace(0, 2*np.pi,9)[:-1]
for i,(trigram,lines) in enumerate(trigrams.items()):
angle =angles[i]
symbol_x=center_x+ radius*np.cos(angle)
symbol_y=center_y+ radius*np.sin(angle)
for j,is_solid in enumerate(lines):
y_pos =symbol_y+(1- j)*size/3
if is_solid:ax.plot([symbol_x-size/3,symbol_x+size/3],[y_pos,y_pos], 'k-',linewidth=2,zorder=2)