Skip to content

Instantly share code, notes, and snippets.

@phyblas
Created October 21, 2017 09:18
Show Gist options
  • Save phyblas/1e6bd68b6f81ce3e113f56ca48853773 to your computer and use it in GitHub Desktop.
Save phyblas/1e6bd68b6f81ce3e113f56ca48853773 to your computer and use it in GitHub Desktop.
สร้างโลโกสำหรับ PyThaiNLP
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap as licama
def rabaisi(x1,y1,x2,y2,si):
n = len(x1)
xt = np.where(np.arange(n)%2,x1,x2)
yt = np.where(np.arange(n)%2,y1,y2)
plt.tripcolor(xt,yt,np.arange(3)+np.arange(n-2)[:,None],facecolors=np.ones(n-2),cmap=licama([si]))
daeng = '#CC4444'
namngoen = '#4444CC'
khiao = '#AAFFAA'
plt.figure(figsize=[4,4])
ax = plt.axes([0,0,1,1],aspect=1,xlim=[-1.4,1.4],ylim=[-1.4,1.4])
p = []
theta = np.linspace(0,360,361)
x0 = np.cos(np.radians(theta))*(1+0.3*np.cos(np.radians((theta+45)))**2)-0.2
y0 = np.sin(np.radians(theta))/2
yh = np.cos(np.radians((theta+45)*2))+1.1*(np.abs(theta-175)<45)*(1-(theta-175)**2/45**2)
y1 = y0*(0.3+yh)-0.5
y2 = y0*(0.2+yh)-0.5
y3 = y0*(0.1+yh)-0.5
cos = np.cos(np.pi/4)
sin = np.sin(np.pi/4)
x1,y1 = x0*cos-y1*sin,x0*sin+y1*cos
x2,y2 = x0*cos-y2*sin,x0*sin+y2*cos
x3,y3 = x0*cos-y3*sin,x0*sin+y3*cos
for i in range(2):
if(i):
x1,x2,x3,y1,y2,y3 = -x1,-x2,-x3,-y1,-y2,-y3
si = 'w'
else:
si = khiao
rabaisi(x1,y1,x2,y2,daeng)
rabaisi(x2,y2,x3,y3,si)
rabaisi(x3[:181],y3[:181],x3[180:][::-1],y3[180:][::-1],namngoen)
h = np.where(i,-1,1)
p += [mpl.patches.Ellipse([-0.65*h,-1*h],0.18,0.18,fc='#d8618a',lw=2,ec=si)]
p += [mpl.patches.Ellipse([-0.65*h,-1*h],0.08,0.08,fc='#6f2525')]
p += [mpl.patches.Ellipse([-0.62*h,-0.97*h],0.04,0.04,fc='w')]
for x in p:
ax.add_patch(x)
plt.text(-0.9,0.8,'P',ha='center',fontsize=75,fontname='Eak Chawlewhieng UNI',color=namngoen,rotation=15)
plt.text(-0.6,0.8,'y',ha='center',fontsize=75,fontname='Eak Chawlewhieng UNI',color=daeng,rotation=15)
plt.text(0.55,-0.15,u'ไทย',ha='center',fontsize=92,fontname='Eak Chulee UNI',color=namngoen,rotation=15)
plt.text(0.53,-0.17,u'ไทย',ha='center',fontsize=92,fontname='Eak Chulee UNI',color=daeng,rotation=15)
plt.text(-0.36,-0.26,'Thai',ha='center',fontsize=70,fontname='Eak Chawlewhieng UNI',color=daeng,rotation=15)
plt.text(-0.38,-0.28,'Thai',ha='center',fontsize=70,fontname='Eak Chawlewhieng UNI',color=khiao,rotation=15)
plt.text(-0.4,-0.3,'Thai',ha='center',fontsize=70,fontname='Eak Chawlewhieng UNI',color=namngoen,rotation=15)
plt.text(0.3,-1.1,'N',ha='center',fontsize=75,fontname='Eak Chawlewhieng UNI',color=daeng,rotation=15)
plt.text(0.73,-1.05,'L',ha='center',fontsize=75,fontname='Eak Chawlewhieng UNI',color=khiao,rotation=15)
plt.text(1.05,-1.,'P',ha='center',fontsize=75,fontname='Eak Chawlewhieng UNI',color=namngoen,rotation=15)
plt.setp([ax.spines[x] for x in ax.spines],lw=0)
plt.savefig('logopythainlp.png',dpi=150)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment